public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Haotian Zhang <vulab@iscas.ac.cn>
To: sean@mess.org, mchehab@kernel.org
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	Haotian Zhang <vulab@iscas.ac.cn>
Subject: [PATCH] media: ttusbir: fix race between device disconnection and urb callback
Date: Fri, 14 Nov 2025 18:14:18 +0800	[thread overview]
Message-ID: <20251114101418.2548-1-vulab@iscas.ac.cn> (raw)

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 <vulab@iscas.ac.cn>
---
 drivers/media/rc/ttusbir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/rc/ttusbir.c b/drivers/media/rc/ttusbir.c
index 560a26f3965c..c1fbbc03dd29 100644
--- a/drivers/media/rc/ttusbir.c
+++ b/drivers/media/rc/ttusbir.c
@@ -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);
-- 
2.50.1.windows.1


                 reply	other threads:[~2025-11-14 10:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251114101418.2548-1-vulab@iscas.ac.cn \
    --to=vulab@iscas.ac.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sean@mess.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox