Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <dinghao.liu@zju.edu.cn>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

authored by

Dinghao Liu and committed by
Jiri Kosina
b7429ea5 724a419e

+2
+2
drivers/hid/hid-elan.c
··· 188 188 ret = input_mt_init_slots(input, ELAN_MAX_FINGERS, INPUT_MT_POINTER); 189 189 if (ret) { 190 190 hid_err(hdev, "Failed to init elan MT slots: %d\n", ret); 191 + input_free_device(input); 191 192 return ret; 192 193 } 193 194 ··· 199 198 if (ret) { 200 199 hid_err(hdev, "Failed to register elan input device: %d\n", 201 200 ret); 201 + input_mt_destroy_slots(input); 202 202 input_free_device(input); 203 203 return ret; 204 204 }