From: Sean Young <sean@mess.org>
To: Haotian Zhang <vulab@iscas.ac.cn>
Cc: mchehab@kernel.org, linux-media@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] media: mceusb: fix race between device disconnection and urb callback
Date: Sat, 20 Dec 2025 16:06:28 +0000 [thread overview]
Message-ID: <aUbJhEhuGTyu24TU@gofer.mess.org> (raw)
In-Reply-To: <20251114101432.2566-1-vulab@iscas.ac.cn>
On Fri, Nov 14, 2025 at 06:14:31PM +0800, Haotian Zhang wrote:
> 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.
First of all, I must apologise for not responding earlier. Haotian, you
have found a real issue here, thank you for finding and reporting it.
I've been thinking about this for some time now. I think I've found an
alternative solution, which I'l shortly be posting to the list.
Thank you
Sean
>
> 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
prev parent reply other threads:[~2025-12-20 16:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-14 10:14 Haotian Zhang
2025-12-20 16:06 ` Sean Young [this message]
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=aUbJhEhuGTyu24TU@gofer.mess.org \
--to=sean@mess.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=vulab@iscas.ac.cn \
/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
all inboxes | Powered by JetHome®