]> git.hungrycats.org Git - linux/commit
HID: mcp2221: always initialize and cancel init_work
authorMyeonghun Pak <mhun512@gmail.com>
Fri, 2 Oct 2026 21:44:16 +0000 (17:44 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Nov 2026 17:10:50 +0000 (12:10 -0500)
commit19711bd64d60378137353ac3e6b774bd3a660f89
treec4d9c657dea0268601ba6e02250ef6c7ffe39aea
parent6ee339f14d81da30909075f2dc88926dd317591a
HID: mcp2221: always initialize and cancel init_work

commit 6a006ff898b459e0bd10375d7fbe0ea7f7a132b9 upstream.

The writable gpio_mode_enforce parameter can change between probe and
remove.

If it changes from false to true after probe, remove skips cancellation
of init_work. Pending or running work can then access devm-managed
driver state after teardown. Changing it from true to false can make
remove cancel an uninitialized delayed work item.

Initialize init_work whenever IIO is reachable and cancel it
unconditionally on remove. Keep the parameter check only for scheduling
the initialization.

The false-to-true cancellation gap was previously reported by Sashiko.
We also encountered this issue during our static-analysis research.

Fixes: 200e6c6e94fa ("HID: mcp2221: Add module parameter to enfoce GPIO mode")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://lore.kernel.org/linux-input/20260715143415.916A21F00A3A@smtp.kernel.org/
Assisted-by: LLM
Cc: stable@vger.kernel.org
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hid/hid-mcp2221.c