Commit b7429ea5 authored by Dinghao Liu's avatar Dinghao Liu Committed by Jiri Kosina

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: default avatarDinghao Liu <dinghao.liu@zju.edu.cn>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 724a419e
...@@ -188,6 +188,7 @@ static int elan_input_configured(struct hid_device *hdev, struct hid_input *hi) ...@@ -188,6 +188,7 @@ static int elan_input_configured(struct hid_device *hdev, struct hid_input *hi)
ret = input_mt_init_slots(input, ELAN_MAX_FINGERS, INPUT_MT_POINTER); ret = input_mt_init_slots(input, ELAN_MAX_FINGERS, INPUT_MT_POINTER);
if (ret) { if (ret) {
hid_err(hdev, "Failed to init elan MT slots: %d\n", ret); hid_err(hdev, "Failed to init elan MT slots: %d\n", ret);
input_free_device(input);
return ret; return ret;
} }
...@@ -198,6 +199,7 @@ static int elan_input_configured(struct hid_device *hdev, struct hid_input *hi) ...@@ -198,6 +199,7 @@ static int elan_input_configured(struct hid_device *hdev, struct hid_input *hi)
if (ret) { if (ret) {
hid_err(hdev, "Failed to register elan input device: %d\n", hid_err(hdev, "Failed to register elan input device: %d\n",
ret); ret);
input_mt_destroy_slots(input);
input_free_device(input); input_free_device(input);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment