[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251110172943.99887-1-nihaal@cse.iitm.ac.in>
Date: Mon, 10 Nov 2025 22:59:41 +0530
From: Abdun Nihaal <nihaal@....iitm.ac.in>
To: jikos@...nel.org
Cc: Abdun Nihaal <nihaal@....iitm.ac.in>,
bentiss@...nel.org,
linux-input@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] 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@....iitm.ac.in>
---
Compile tested only. Found using static analysis.
drivers/hid/hid-uclogic-params.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c
index 59ea71299438..e28176d9d9c9 100644
--- a/drivers/hid/hid-uclogic-params.c
+++ b/drivers/hid/hid-uclogic-params.c
@@ -1372,8 +1372,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);
--
2.43.0
Powered by blists - more mailing lists