summaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>2018-03-19 21:53:27 +0100
committerJiri Kosina <jkosina@suse.cz>2018-04-26 14:33:35 +0200
commitedb6cb3d7c9026d1a3bdfde9f74ed6c807285206 (patch)
treec1c10619a7ca56a487ae360e704eb95729d6cc71 /drivers/hid
parent605f077290a594c75a952ad3b78e53d68c1895ae (diff)
downloadop-kernel-dev-edb6cb3d7c9026d1a3bdfde9f74ed6c807285206.zip
op-kernel-dev-edb6cb3d7c9026d1a3bdfde9f74ed6c807285206.tar.gz
HID: alps: Save a memory allocation in 't4_read_write_register()' when writing data
if 'read_flag' is false, there is no need to allocate and free memory. We can simply avoid the memory allocation and pass NULL to kfree. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/hid-alps.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/hid/hid-alps.c b/drivers/hid/hid-alps.c
index 925396f..fe8a062 100644
--- a/drivers/hid/hid-alps.c
+++ b/drivers/hid/hid-alps.c
@@ -171,7 +171,7 @@ static int t4_read_write_register(struct hid_device *hdev, u32 address,
int ret;
u16 check_sum;
u8 *input;
- u8 *readbuf;
+ u8 *readbuf = NULL;
input = kzalloc(T4_FEATURE_REPORT_LEN, GFP_KERNEL);
if (!input)
@@ -204,8 +204,8 @@ static int t4_read_write_register(struct hid_device *hdev, u32 address,
goto exit;
}
- readbuf = kzalloc(T4_FEATURE_REPORT_LEN, GFP_KERNEL);
if (read_flag) {
+ readbuf = kzalloc(T4_FEATURE_REPORT_LEN, GFP_KERNEL);
if (!readbuf) {
ret = -ENOMEM;
goto exit;
OpenPOWER on IntegriCloud