[PATCH] HID: i2c-hid: fix memory leak during probe

Subsystems: hid core layer, the rest

STALE5015d

2 messages, 2 authors, 2012-11-20 · open the first message on its own page

[PATCH] HID: i2c-hid: fix memory leak during probe

From: Jiri Kosina <hidden>
Date: 2012-11-20 16:09:46

In case we are returning from i2c_hid_probe() through the 'err' or 
err_mem_free labels, there is noone freeing the buffers allocated by 
i2c_hid_alloc_buffers().

Signed-off-by: Jiri Kosina <redacted>
---
 drivers/hid/i2c-hid/i2c-hid.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index 11140bd..67ab5b7 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -892,6 +892,7 @@ err:
 	if (ihid->irq)
 		free_irq(ihid->irq, ihid);
 
+	i2c_hid_free_buffers(ihid);
 	kfree(ihid);
 	return ret;
 }
-- 
Jiri Kosina
SUSE Labs

Re: [PATCH] HID: i2c-hid: fix memory leak during probe

From: Benjamin Tissoires <hidden>
Date: 2012-11-20 16:34:08

On Tue, Nov 20, 2012 at 5:09 PM, Jiri Kosina [off-list ref] wrote:
In case we are returning from i2c_hid_probe() through the 'err' or
err_mem_free labels, there is noone freeing the buffers allocated by
i2c_hid_alloc_buffers().
ouch... thanks Jiri
I hope there are not so much others like this one :)

Reviewed-by: Benjamin Tissoires <redacted>
quoted hunk
Signed-off-by: Jiri Kosina <redacted>
---
 drivers/hid/i2c-hid/i2c-hid.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index 11140bd..67ab5b7 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -892,6 +892,7 @@ err:
        if (ihid->irq)
                free_irq(ihid->irq, ihid);

+       i2c_hid_free_buffers(ihid);
        kfree(ihid);
        return ret;
 }

--
Jiri Kosina
SUSE Labs
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help