]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Nov 2025 09:35:58 +0000 (10:35 +0100)
[ Upstream commit a78eb69d60ce893de48dd75f725ba21309131fc2 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hid/hid-uclogic-params.c

index ef26c7defcf61ced86b07100002e572780f23305..89fa2610f02ba8777dd8718da1fda02dfa1b8b03 100644 (file)
@@ -1367,8 +1367,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);