Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

HID: uclogic: Fix potential memory leak in error path

In uclogic_params_ugee_v2_init_event_hooks(), the memory allocated for
event_hook is not freed in the next error path. Fix that by freeing it.

Fixes: a251d6576d2a ("HID: uclogic: Handle wireless device reconnection")
Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
Signed-off-by: Jiri Kosina <jkosina@suse.com>

authored by

Abdun Nihaal and committed by
Jiri Kosina
a78eb69d 8513c154

+3 -1
+3 -1
drivers/hid/hid-uclogic-params.c
··· 1369 1369 event_hook->hdev = hdev; 1370 1370 event_hook->size = ARRAY_SIZE(reconnect_event); 1371 1371 event_hook->event = kmemdup(reconnect_event, event_hook->size, GFP_KERNEL); 1372 - if (!event_hook->event) 1372 + if (!event_hook->event) { 1373 + kfree(event_hook); 1373 1374 return -ENOMEM; 1375 + } 1374 1376 1375 1377 list_add_tail(&event_hook->list, &p->event_hooks->list); 1376 1378