Commit e8f75a5b authored by Miaoqian Lin's avatar Miaoqian Lin Committed by Chen Ridong
Browse files

HID: elan: Fix potential double free in elan_input_configured

stable inclusion
from stable-v4.19.24
commit c92ec22a991778a096342cf1a917ae36c5c86a90
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBP38D
CVE: CVE-2022-49508

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=c92ec22a991778a096342cf1a917ae36c5c86a90



----------------------------------------------------------------------

[ Upstream commit 1af20714 ]

'input' is a managed resource allocated with devm_input_allocate_device(),
so there is no need to call input_free_device() explicitly or
there will be a double free.

According to the doc of devm_input_allocate_device():
 * Managed input devices do not need to be explicitly unregistered or
 * freed as it will be done automatically when owner device unbinds from
 * its driver (or binding fails).

Fixes: b7429ea5 ("HID: elan: Fix memleak in elan_input_configured")
Fixes: 9a6a4193 ("HID: Add driver for USB ELAN Touchpad")
Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
Acked-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarChen Ridong <chenridong@huawei.com>
parent a9fadff7
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -192,7 +192,6 @@ 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;
	}

@@ -204,7 +203,6 @@ static int elan_input_configured(struct hid_device *hdev, struct hid_input *hi)
		hid_err(hdev, "Failed to register elan input device: %d\n",
			ret);
		input_mt_destroy_slots(input);
		input_free_device(input);
		return ret;
	}