diff mbox

HID: i2c-hid: fix memory leak during probe

Message ID alpine.LNX.2.00.1211201706300.4609@pobox.suse.cz (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

Jiri Kosina Nov. 20, 2012, 4:09 p.m. UTC
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 <jkosina@suse.cz>
---
 drivers/hid/i2c-hid/i2c-hid.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Comments

Benjamin Tissoires Nov. 20, 2012, 4:34 p.m. UTC | #1
On Tue, Nov 20, 2012 at 5:09 PM, Jiri Kosina <jkosina@suse.cz> 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 <benjamin.tissoires@gmail.com>

>
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
> ---
>  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
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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;
 }