mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
HID: uclogic: Fix potential memory leak in error path
[ Upstream commita78eb69d60] 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:a251d6576d("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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
c0404220cf
commit
67d7949cd3
@@ -1369,8 +1369,10 @@ static int uclogic_params_ugee_v2_init_event_hooks(struct hid_device *hdev,
|
|||||||
event_hook->hdev = hdev;
|
event_hook->hdev = hdev;
|
||||||
event_hook->size = ARRAY_SIZE(reconnect_event);
|
event_hook->size = ARRAY_SIZE(reconnect_event);
|
||||||
event_hook->event = kmemdup(reconnect_event, event_hook->size, GFP_KERNEL);
|
event_hook->event = kmemdup(reconnect_event, event_hook->size, GFP_KERNEL);
|
||||||
if (!event_hook->event)
|
if (!event_hook->event) {
|
||||||
|
kfree(event_hook);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
list_add_tail(&event_hook->list, &p->event_hooks->list);
|
list_add_tail(&event_hook->list, &p->event_hooks->list);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user