Commit a78eb69d authored by Abdun Nihaal's avatar Abdun Nihaal Committed by Jiri Kosina
Browse files

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: a251d657 ("HID: uclogic: Handle wireless device reconnection")
Signed-off-by: default avatarAbdun Nihaal <nihaal@cse.iitm.ac.in>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.com>
parent 8513c154
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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);