Skip to content

Commit fd34bf7

Browse files
qasim-ijazJiri Kosina
authored andcommitted
HID: wacom: fix memory leak on size mismatch in wacom_wac_queue_flush()
In wacom_wac_queue_flush() the code allocates zero initialised buffer which it uses as a storage buffer for copying data from a fifo via kfifo_out(). The kfifo_out() function returns the number of elements it has copied. The code checks if the number of copied elements does not equal the size of the fifo record, if it does not it simply skips the entry and continues to the next iteration. However it does not release the storage buffer leading to a memory leak. Fix the memory leak by freeing the buffer on size mismatch. Fixes: 5e013ad ("HID: wacom: Remove static WACOM_PKGLEN_MAX limit") Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com> Signed-off-by: Qasim Ijaz <qasdev00@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
1 parent e1ca5f3 commit fd34bf7

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/hid/wacom_sys.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ static void wacom_wac_queue_flush(struct hid_device *hdev,
8787
// to flush seems reasonable enough, however.
8888
hid_warn(hdev, "%s: removed fifo entry with unexpected size\n",
8989
__func__);
90+
kfree(buf);
9091
continue;
9192
}
9293
err = hid_report_raw_event(hdev, HID_INPUT_REPORT, buf, size, false);

0 commit comments

Comments
 (0)