aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorQasim Ijaz <qasdev00@gmail.com>2025-03-29 00:20:03 +0000
committerJiri Kosina <jkosina@suse.com>2025-04-24 11:53:35 +0200
commite1ca5f39c2e37a3a8cdae005b94c3fc385be4240 (patch)
tree94b470622d1daf25b2daed08b9a00a47c857695d /drivers/hid
parentHID: thrustmaster: fix memory leak in thrustmaster_interrupts() (diff)
downloadlinux-rng-e1ca5f39c2e37a3a8cdae005b94c3fc385be4240.tar.xz
linux-rng-e1ca5f39c2e37a3a8cdae005b94c3fc385be4240.zip
HID: wacom: handle kzalloc() allocation failure in wacom_wac_queue_flush()
During wacom_wac_queue_flush() the code calls kzalloc() to allocate a zero initialised buffer which it uses as a storage buffer to get data from the fifo via kfifo_out(). However it does not check kzalloc() for allocation failure which returns NULL and could potentially lead to a NULL deref. Fix this by checking for kzalloc() failure and skipping the current entry if allocation failure occurs. Fixes: 5e013ad20689 ("HID: wacom: Remove static WACOM_PKGLEN_MAX limit") Signed-off-by: Qasim Ijaz <qasdev00@gmail.com> Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/wacom_sys.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 97393a3083ca..43d892810c9e 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -70,10 +70,16 @@ static void wacom_wac_queue_flush(struct hid_device *hdev,
{
while (!kfifo_is_empty(fifo)) {
int size = kfifo_peek_len(fifo);
- u8 *buf = kzalloc(size, GFP_KERNEL);
+ u8 *buf;
unsigned int count;
int err;
+ buf = kzalloc(size, GFP_KERNEL);
+ if (!buf) {
+ kfifo_skip(fifo);
+ continue;
+ }
+
count = kfifo_out(fifo, buf, size);
if (count != size) {
// Hard to say what is the "right" action in this