Skip to content

Commit

Permalink
HID: alps: Save a memory allocation in 't4_read_write_register()' whe…
Browse files Browse the repository at this point in the history
…n 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 <[email protected]>
Signed-off-by: Jiri Kosina <[email protected]>
  • Loading branch information
tititiou36 authored and Jiri Kosina committed Apr 26, 2018
1 parent 605f077 commit edb6cb3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/hid/hid-alps.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit edb6cb3

Please sign in to comment.