提交 edb6cb3d 编写于 作者: C Christophe JAILLET 提交者: Jiri Kosina

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: NChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
上级 605f0772
...@@ -171,7 +171,7 @@ static int t4_read_write_register(struct hid_device *hdev, u32 address, ...@@ -171,7 +171,7 @@ static int t4_read_write_register(struct hid_device *hdev, u32 address,
int ret; int ret;
u16 check_sum; u16 check_sum;
u8 *input; u8 *input;
u8 *readbuf; u8 *readbuf = NULL;
input = kzalloc(T4_FEATURE_REPORT_LEN, GFP_KERNEL); input = kzalloc(T4_FEATURE_REPORT_LEN, GFP_KERNEL);
if (!input) if (!input)
...@@ -204,8 +204,8 @@ static int t4_read_write_register(struct hid_device *hdev, u32 address, ...@@ -204,8 +204,8 @@ static int t4_read_write_register(struct hid_device *hdev, u32 address,
goto exit; goto exit;
} }
readbuf = kzalloc(T4_FEATURE_REPORT_LEN, GFP_KERNEL);
if (read_flag) { if (read_flag) {
readbuf = kzalloc(T4_FEATURE_REPORT_LEN, GFP_KERNEL);
if (!readbuf) { if (!readbuf) {
ret = -ENOMEM; ret = -ENOMEM;
goto exit; goto exit;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册