media: ttusbir: fix race between device disconnection and urb callback
PATCH 1/1 media: ttusbir: fix race between device disconnection and urb callback
The ttusbir_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 ttusbir_urb_complete() is still running, ttusbir_process_ir_data() may call ir_raw_event_store_with_filter() or ir_raw_event_handle() with a freed tt->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 0938069fa089 ("[media] rc: Add support for the TechnoTrend USB IR Receiver")
Signed-off-by Haotian Zhang <[email protected]>
--- drivers/media/rc/ttusbir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/rc/ttusbir.c +1 -1
@@ -363,7 +363,6 @@ static void ttusbir_disconnect(struct usb_interface *intf) tt->udev =NULL ; -rc_unregister_device (tt->rc);led_classdev_unregister (&tt->led);for (i =0 ; i <NUM_URBS ; i++) {usb_kill_urb (tt->urb[i]);
@@ -372,6 +371,7 @@ static void ttusbir_disconnect(struct usb_interface *intf)usb_free_urb (tt->urb[i]); }usb_kill_urb (tt->bulk_urb); +rc_unregister_device (tt->rc);usb_free_urb (tt->bulk_urb);usb_set_intfdata (intf,NULL );kfree (tt);
Signature · 1 line
2.50.1.windows.1