HID: hid-picolcd: Fix memory leak in picolcd_debug_out_report()
authorJesper Juhl <jj@chaosbits.net>
Sun, 2 Jan 2011 21:17:00 +0000 (22:17 +0100)
committerJiri Kosina <jkosina@suse.cz>
Sun, 2 Jan 2011 23:11:30 +0000 (00:11 +0100)
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@chaosbits.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-picolcd.c

index 0aff3cdddd83f77dcc5aabfe05cfa218ebbbfc22..abd0bdc84624ab773f60a727d80b65924f91ca60 100644 (file)
@@ -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 {