All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] HID: sony: fix use-after-free when removing GHL devices
@ 2026-08-07  5:23 Fan Wu
  2026-08-07  5:37 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Fan Wu @ 2026-08-07  5:23 UTC (permalink / raw)
  To: jikos, bentiss, linux-input; +Cc: linux-kernel, Fan Wu, stable, Pascal Giard

The GHL poke timer and its control URB re-arm each other: the timer
callback submits the URB, and the URB completion re-arms the timer.

sony_remove() only called timer_delete_sync(), which waits for a running
callback but does not stop a URB the callback already submitted and does
not stop the completion from re-arming the timer.  The sony_sc structure
is devm-allocated and freed after sony_remove() returns, so on removal
the completion or the re-armed timer can run on freed memory.

Use timer_shutdown_sync() instead, which also detaches the callback so
the completion can no longer re-arm the timer, and add usb_kill_urb()
before usb_free_urb() to drain any URB the callback submitted.  The URB
is driver-private and not anchored, so hid_hw_stop() does not touch it.

Found by a static analysis tool.

Fixes: fb1a79a6b6e1 ("HID: sony: fix freeze when inserting ghlive ps3/wii dongles")
Cc: stable@vger.kernel.org
Cc: Pascal Giard <pascal.giard@etsmtl.ca>
Assisted-by: Codex:gpt-5.6
Signed-off-by: Fan Wu <fanwu01@zju.edu.cn>
---
 drivers/hid/hid-sony.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index b966e4044238..bbd95adfbed6 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -2164,7 +2164,8 @@ static void sony_remove(struct hid_device *hdev)
 	struct sony_sc *sc = hid_get_drvdata(hdev);
 
 	if (sc->quirks & (GHL_GUITAR_PS3WIIU | GHL_GUITAR_PS4)) {
-		timer_delete_sync(&sc->ghl_poke_timer);
+		timer_shutdown_sync(&sc->ghl_poke_timer);
+		usb_kill_urb(sc->ghl_urb);
 		usb_free_urb(sc->ghl_urb);
 	}
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-07  5:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-07  5:23 [PATCH] HID: sony: fix use-after-free when removing GHL devices Fan Wu
2026-08-07  5:37 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.