HID: intel-ish-hid: ipc: Fix potential use-after-free in work function
authorReka Norman <rekanorman@chromium.org>
Mon, 27 Feb 2023 02:49:38 +0000 (13:49 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Mar 2023 10:49:16 +0000 (12:49 +0200)
commit0a594cb490ca6232671fc09e2dc1a0fc7ccbb0b5
tree77b7dad81d6f93971af3fc2b11ac1a8da6e0bfec
parente6f150861b281a4ea9cee63800089f08149cbb8c
HID: intel-ish-hid: ipc: Fix potential use-after-free in work function

[ Upstream commit 8ae2f2b0a28416ed2f6d8478ac8b9f7862f36785 ]

When a reset notify IPC message is received, the ISR schedules a work
function and passes the ISHTP device to it via a global pointer
ishtp_dev. If ish_probe() fails, the devm-managed device resources
including ishtp_dev are freed, but the work is not cancelled, causing a
use-after-free when the work function tries to access ishtp_dev. Use
devm_work_autocancel() instead, so that the work is automatically
cancelled if probe fails.

Signed-off-by: Reka Norman <rekanorman@chromium.org>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hid/intel-ish-hid/ipc/ipc.c