* [PATCH 1/1] hid: sensor-hub, fix potential memory leak
@ 2014-06-30 9:34 Jiri Slaby
2014-06-30 11:22 ` Jiri Kosina
0 siblings, 1 reply; 2+ messages in thread
From: Jiri Slaby @ 2014-06-30 9:34 UTC (permalink / raw)
To: jkosina
Cc: linux-kernel, linux-input, jirislaby, Jiri Slaby,
srinivas pandruvada
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>
Cc: Jiri Kosina <jkosina@suse.cz>
---
drivers/hid/hid-sensor-hub.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index a8d5c8faf8cf..584e17ce80e4 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -632,6 +632,7 @@ static int sensor_hub_probe(struct hid_device *hdev,
if (name == NULL) {
hid_err(hdev, "Failed MFD device name\n");
ret = -ENOMEM;
+ kfree(hsdev);
goto err_no_mem;
}
sd->hid_sensor_hub_client_devs[
--
2.0.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] hid: sensor-hub, fix potential memory leak
2014-06-30 9:34 [PATCH 1/1] hid: sensor-hub, fix potential memory leak Jiri Slaby
@ 2014-06-30 11:22 ` Jiri Kosina
0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2014-06-30 11:22 UTC (permalink / raw)
To: Jiri Slaby; +Cc: linux-kernel, linux-input, jirislaby, srinivas pandruvada
On Mon, 30 Jun 2014, Jiri Slaby wrote:
> 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>
> Cc: Jiri Kosina <jkosina@suse.cz>
> ---
> drivers/hid/hid-sensor-hub.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
> index a8d5c8faf8cf..584e17ce80e4 100644
> --- a/drivers/hid/hid-sensor-hub.c
> +++ b/drivers/hid/hid-sensor-hub.c
> @@ -632,6 +632,7 @@ static int sensor_hub_probe(struct hid_device *hdev,
> if (name == NULL) {
> hid_err(hdev, "Failed MFD device name\n");
> ret = -ENOMEM;
> + kfree(hsdev);
> goto err_no_mem;
> }
> sd->hid_sensor_hub_client_devs[
Applied, thanks.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-06-30 11:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-30 9:34 [PATCH 1/1] hid: sensor-hub, fix potential memory leak Jiri Slaby
2014-06-30 11:22 ` Jiri Kosina
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).