Re: [PATCH] HID: hid-lenovo-go: cancel cfg_setup work in hid_go_cfg_remove()
From: Jiri Kosina
Date: Wed Jun 03 2026 - 08:25:08 EST
On Fri, 15 May 2026, Manish Khadka wrote:
> hid_go_cfg_probe() initialises drvdata.go_cfg_setup and schedules it
> to run 2 ms later:
>
> INIT_DELAYED_WORK(&drvdata.go_cfg_setup, &cfg_setup);
> schedule_delayed_work(&drvdata.go_cfg_setup, msecs_to_jiffies(2));
>
> cfg_setup() dereferences drvdata.hdev to issue MCU command requests.
> hid_go_cfg_remove() tears down sysfs and stops the HID device, ending
> with hid_set_drvdata(hdev, NULL), but never drains the delayed work.
> If the device is unbound within the 2 ms scheduling delay (a probe
> failure rolling back via remove, or a fast rmmod after probe), the
> work fires after hid_set_drvdata(NULL) has cleared the back pointer,
> leaving cfg_setup() with a NULL or stale drvdata.hdev.
>
> Mirror the sibling driver hid-lenovo-go-s.c, whose hid_gos_cfg_remove()
> already calls cancel_delayed_work_sync() on its analogous work, and
> drain go_cfg_setup at the top of hid_go_cfg_remove(). The cancel
> must come before guard(mutex)(&drvdata.cfg_mutex) because cfg_setup()
> acquires that mutex; reversing the order would deadlock.
>
> Fixes: d69ccfcbc955 ("HID: hid-lenovo-go: Add Lenovo Legion Go Series HID Driver")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Manish Khadka <maskmemanish@xxxxxxxxx>
Applied, thanks.
--
Jiri Kosina
SUSE Labs