mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 16:24:13 +08:00
HID: alps: Fix memory leak
A kfree(readbuf) call was missed if hid_hw_raw_request() fails, fix it. Also avoid mixing direct return with goto in the error paths. Signed-off-by: Axel Lin <axel.lin@ingics.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
parent
b490a8537d
commit
7ee2eaa364
@ -139,8 +139,8 @@ static int u1_read_write_register(struct hid_device *hdev, u32 address,
|
||||
if (read_flag) {
|
||||
readbuf = kzalloc(U1_FEATURE_REPORT_LEN, GFP_KERNEL);
|
||||
if (!readbuf) {
|
||||
kfree(input);
|
||||
return -ENOMEM;
|
||||
ret = -ENOMEM;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ret = hid_hw_raw_request(hdev, U1_FEATURE_REPORT_ID, readbuf,
|
||||
@ -149,6 +149,7 @@ static int u1_read_write_register(struct hid_device *hdev, u32 address,
|
||||
|
||||
if (ret < 0) {
|
||||
dev_err(&hdev->dev, "failed read register (%d)\n", ret);
|
||||
kfree(readbuf);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user