Commit ceec6340 authored by Jiri Slaby's avatar Jiri Slaby Committed by Jiri Kosina

HID: sensor-hub: fix potential memory leak

hsdev is not freed in sensor_hub_probe when kasprintf inside the for
loop fails. This is because hsdev is not set to platform_data yet (to
be freed by the code in the err_no_mem label). So free the memory
explicitly in the 'if' branch, as this is the only place where this is
(and will) be needed.

Reported-by: coverity
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Cc: srinivas pandruvada <srinivas.pandruvada@intel.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 66e54827
...@@ -636,6 +636,7 @@ static int sensor_hub_probe(struct hid_device *hdev, ...@@ -636,6 +636,7 @@ static int sensor_hub_probe(struct hid_device *hdev,
if (name == NULL) { if (name == NULL) {
hid_err(hdev, "Failed MFD device name\n"); hid_err(hdev, "Failed MFD device name\n");
ret = -ENOMEM; ret = -ENOMEM;
kfree(hsdev);
goto err_no_mem; goto err_no_mem;
} }
sd->hid_sensor_hub_client_devs[ sd->hid_sensor_hub_client_devs[
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment