]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
HID: elan: Fix memleak in elan_input_configured
authorDinghao Liu <dinghao.liu@zju.edu.cn>
Mon, 31 Aug 2020 09:06:43 +0000 (17:06 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 9 Nov 2020 13:46:44 +0000 (14:46 +0100)
BugLink: https://bugs.launchpad.net/bugs/1896824
[ Upstream commit b7429ea53d6c0936a0f10a5d64164f0aea440143 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: William Breathitt Gray <william.gray@canonical.com>
drivers/hid/hid-elan.c

index 45c4f888b7c4e61b9adf8f3c2101f337ae14870c..dae193749d443490390255df260fda27edc3e531 100644 (file)
@@ -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);
        if (ret) {
                hid_err(hdev, "Failed to init elan MT slots: %d\n", ret);
+               input_free_device(input);
                return ret;
        }
 
@@ -198,6 +199,7 @@ static int elan_input_configured(struct hid_device *hdev, struct hid_input *hi)
        if (ret) {
                hid_err(hdev, "Failed to register elan input device: %d\n",
                        ret);
+               input_mt_destroy_slots(input);
                input_free_device(input);
                return ret;
        }