Re: [PATCH] HID, hid-picolcd: Fix memory leak inpicolcd_debug_out_report()

From: Jiri Kosina
Date: Sun Jan 02 2011 - 18:12:41 EST


On Sun, 2 Jan 2011, Jesper Juhl wrote:

> We have a memory leak in
> drivers/hid/hid-picolcd.c::picolcd_debug_out_report() in an error path..
> We are not always freeing the memory allocated to 'buff' - this patch
> makes sure we always kfree() what we allocate with kmalloc() when it is
> no longer needed.
>
>
> Signed-off-by: Jesper Juhl <jj@xxxxxxxxxxxxx>
> ---
> hid-picolcd.c | 1 +
> 1 file changed, 1 insertion(+)
>
> compile tested only.
>
> diff --git a/drivers/hid/hid-picolcd.c b/drivers/hid/hid-picolcd.c
> index bc2e077..ad6539a 100644
> --- a/drivers/hid/hid-picolcd.c
> +++ b/drivers/hid/hid-picolcd.c
> @@ -1867,6 +1867,7 @@ static void picolcd_debug_out_report(struct picolcd_data *data,
> report->id, raw_size);
> hid_debug_event(hdev, buff);
> if (raw_size + 5 > sizeof(raw_data)) {
> + kfree(buff);
> hid_debug_event(hdev, " TOO BIG\n");
> return;
> } else {
>

Good catch, applied, thanks Jesper.

--
Jiri Kosina
SUSE Labs, Novell Inc.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/