[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200907163426.1281284-18-sashal@kernel.org>
Date: Mon, 7 Sep 2020 12:34:18 -0400
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
Cc: Dinghao Liu <dinghao.liu@....edu.cn>,
Jiri Kosina <jkosina@...e.cz>, Sasha Levin <sashal@...nel.org>,
linux-input@...r.kernel.org
Subject: [PATCH AUTOSEL 4.19 18/26] HID: elan: Fix memleak in elan_input_configured
From: Dinghao Liu <dinghao.liu@....edu.cn>
[ 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@....edu.cn>
Signed-off-by: Jiri Kosina <jkosina@...e.cz>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
drivers/hid/hid-elan.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/hid/hid-elan.c b/drivers/hid/hid-elan.c
index 07e26c3567eb9..6346282e0ff05 100644
--- a/drivers/hid/hid-elan.c
+++ b/drivers/hid/hid-elan.c
@@ -192,6 +192,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;
}
@@ -202,6 +203,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;
}
--
2.25.1
Powered by blists - more mailing lists