]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
HID: uclogic: Fix potential memory leak in error path
authorAbdun Nihaal <nihaal@cse.iitm.ac.in>
Mon, 10 Nov 2025 17:29:41 +0000 (22:59 +0530)
committerJiri Kosina <jkosina@suse.com>
Tue, 18 Nov 2025 17:08:20 +0000 (18:08 +0100)
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>
drivers/hid/hid-uclogic-params.c

index ffa14a4621ef45dc26570347ef2c00c12e0aa279..4c4bac6f792b2fdce490c44cd137cbb82180a41f 100644 (file)
@@ -1369,8 +1369,10 @@ static int uclogic_params_ugee_v2_init_event_hooks(struct hid_device *hdev,
        event_hook->hdev = hdev;
        event_hook->size = ARRAY_SIZE(reconnect_event);
        event_hook->event = kmemdup(reconnect_event, event_hook->size, GFP_KERNEL);
-       if (!event_hook->event)
+       if (!event_hook->event) {
+               kfree(event_hook);
                return -ENOMEM;
+       }
 
        list_add_tail(&event_hook->list, &p->event_hooks->list);