Skip to content

Commit e1ca5f3

Browse files
qasim-ijazJiri Kosina
authored andcommitted
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: 5e013ad ("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>
1 parent 09d5463 commit e1ca5f3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/hid/wacom_sys.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,16 @@ static void wacom_wac_queue_flush(struct hid_device *hdev,
7070
{
7171
while (!kfifo_is_empty(fifo)) {
7272
int size = kfifo_peek_len(fifo);
73-
u8 *buf = kzalloc(size, GFP_KERNEL);
73+
u8 *buf;
7474
unsigned int count;
7575
int err;
7676

77+
buf = kzalloc(size, GFP_KERNEL);
78+
if (!buf) {
79+
kfifo_skip(fifo);
80+
continue;
81+
}
82+
7783
count = kfifo_out(fifo, buf, size);
7884
if (count != size) {
7985
// Hard to say what is the "right" action in this

0 commit comments

Comments
 (0)