diff options
author | Jiri Slaby <jslaby@suse.cz> | 2014-06-30 05:34:48 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2014-06-30 07:21:50 -0400 |
commit | ceec634076b91bea57107541a46e92d765c69488 (patch) | |
tree | e957f71a87e2a28319ef6a63a80489da87e1993d /drivers/hid/hid-sensor-hub.c | |
parent | 66e5482752386786c4346f4f4b214b0998639702 (diff) |
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: Jiri Slaby <jslaby@suse.cz>
Cc: srinivas pandruvada <srinivas.pandruvada@intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-sensor-hub.c')
-rw-r--r-- | drivers/hid/hid-sensor-hub.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index 13ce4e3aebf4..e244e449cbba 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c | |||
@@ -636,6 +636,7 @@ static int sensor_hub_probe(struct hid_device *hdev, | |||
636 | if (name == NULL) { | 636 | if (name == NULL) { |
637 | hid_err(hdev, "Failed MFD device name\n"); | 637 | hid_err(hdev, "Failed MFD device name\n"); |
638 | ret = -ENOMEM; | 638 | ret = -ENOMEM; |
639 | kfree(hsdev); | ||
639 | goto err_no_mem; | 640 | goto err_no_mem; |
640 | } | 641 | } |
641 | sd->hid_sensor_hub_client_devs[ | 642 | sd->hid_sensor_hub_client_devs[ |