mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: mceusb: fix race between device disconnection and urb callback
@ 2025-11-14 10:14 Haotian Zhang
  2025-12-20 16:06 ` Sean Young
  0 siblings, 1 reply; 2+ messages in thread
From: Haotian Zhang @ 2025-11-14 10:14 UTC (permalink / raw)
  To: sean, mchehab; +Cc: linux-media, linux-kernel, Haotian Zhang

The mceusb_disconnect() function calls rc_unregister_device() before
usb_kill_urb(), creating a race condition similar to the one fixed in
commit 'f656cfbc7a29'. If rc_unregister_device() executes while the URB
callback mceusb_dev_recv() is still running, mceusb_process_ir_data()
may call ir_raw_event_store_with_filter() or ir_raw_event_handle() with
a freed ir->rc->raw pointer, leading to a NULL pointer dereference.

Call usb_kill_urb() before rc_unregister_device() to ensure all URB
callbacks complete before freeing device resources.

Fixes: d8b4b5822f51 ("[media] ir-core: make struct rc_dev the primary interface")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
 drivers/media/rc/mceusb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index 044767eb3a38..fb5c393dcb94 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -1845,8 +1845,8 @@ static void mceusb_dev_disconnect(struct usb_interface *intf)
 
 	ir->usbdev = NULL;
 	cancel_work_sync(&ir->kevent);
-	rc_unregister_device(ir->rc);
 	usb_kill_urb(ir->urb_in);
+	rc_unregister_device(ir->rc);
 	usb_free_urb(ir->urb_in);
 	usb_free_coherent(dev, ir->len_in, ir->buf_in, ir->dma_in);
 	usb_put_dev(dev);
-- 
2.50.1.windows.1


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

end of thread, other threads:[~2025-12-20 16:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-14 10:14 [PATCH] media: mceusb: fix race between device disconnection and urb callback Haotian Zhang
2025-12-20 16:06 ` Sean Young

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®