summaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-alps.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2016-09-11 06:09:01 +0200
committerJiri Kosina <jkosina@suse.cz>2016-09-19 14:42:22 +0200
commit7ee2eaa3641827a9ecdffa190cde31846024d2e3 (patch)
tree7c6bdf3921858ee77cbe7c63a7ccc62843d7383e /drivers/hid/hid-alps.c
parentHID: microsoft: Add Surface 4 type cover pro 4 (JP) (diff)
downloadlinux-7ee2eaa3641827a9ecdffa190cde31846024d2e3.tar.xz
linux-7ee2eaa3641827a9ecdffa190cde31846024d2e3.zip
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>
Diffstat (limited to 'drivers/hid/hid-alps.c')
-rw-r--r--drivers/hid/hid-alps.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/hid/hid-alps.c b/drivers/hid/hid-alps.c
index 048befde295a..2808da9ed9c8 100644
--- a/drivers/hid/hid-alps.c
+++ b/drivers/hid/hid-alps.c
@@ -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;
}