Skip to content

Commit b7429ea

Browse files
dinghaoliuJiri Kosina
authored andcommitted
HID: elan: Fix memleak in elan_input_configured
When input_mt_init_slots() fails, input should be freed to prevent memleak. When input_register_device() fails, we should call input_mt_destroy_slots() to free memory allocated by input_mt_init_slots(). Signed-off-by: Dinghao Liu <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 724a419 commit b7429ea

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/hid/hid-elan.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ static int elan_input_configured(struct hid_device *hdev, struct hid_input *hi)
188188
ret = input_mt_init_slots(input, ELAN_MAX_FINGERS, INPUT_MT_POINTER);
189189
if (ret) {
190190
hid_err(hdev, "Failed to init elan MT slots: %d\n", ret);
191+
input_free_device(input);
191192
return ret;
192193
}
193194

@@ -198,6 +199,7 @@ static int elan_input_configured(struct hid_device *hdev, struct hid_input *hi)
198199
if (ret) {
199200
hid_err(hdev, "Failed to register elan input device: %d\n",
200201
ret);
202+
input_mt_destroy_slots(input);
201203
input_free_device(input);
202204
return ret;
203205
}

0 commit comments

Comments
 (0)