* [PATCH] most: usb: don't use a NULL device on disconnect
@ 2026-10-27 16:33 Greg Kroah-Hartman
0 siblings, 0 replies; only message in thread
From: Greg Kroah-Hartman @ 2026-10-27 16:33 UTC (permalink / raw)
To: parthiban.veerasooran, christian.gromm
Cc: linux-kernel, Josef Bacik, stable, Greg Kroah-Hartman
From: Josef Bacik <josef@toxicpanda.com>
hdm_disconnect() clears mdev->usb_device before it stops the link status
timer and the work which that timer schedules. wq_netinfo() does not
expect a NULL pointer: it hands it to drci_rd_reg(), which dereferences
it. Stop the timer and the work first.
The interface stays registered until the end of hdm_disconnect(), so
hdm_request_netinfo() can still be called and arm the timer. Shut the
timer down, rather than delete it, so that this has no effect.
wq_clear_halt() has the same problem. It is only cancelled when the
channels are poisoned, by most_deregister_interface(), and cannot be
cancelled earlier since the URB handlers schedule it. It takes io_mutex,
like the code which clears the pointer, so test the pointer there.
Fixes: a4198cdf0c34 ("Staging: most: add MOST driver's hdm-usb module")
Cc: stable <stable@kernel.org>
Cc: Parthiban Veerasooran <parthiban.veerasooran@microchip.com>
Cc: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/most/most_usb.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/most/most_usb.c b/drivers/most/most_usb.c
index 6437733afee0..9485f5a51f5f 100644
--- a/drivers/most/most_usb.c
+++ b/drivers/most/most_usb.c
@@ -735,6 +735,10 @@ static void wq_clear_halt(struct work_struct *wq_obj)
int peer;
mutex_lock(&mdev->io_mutex);
+ if (!mdev->usb_device) {
+ mutex_unlock(&mdev->io_mutex);
+ return;
+ }
most_stop_enqueue(&mdev->iface, channel);
usb_kill_anchored_urbs(&mdev->busy_urbs[channel]);
if (usb_clear_halt(mdev->usb_device, pipe))
@@ -1108,14 +1112,15 @@ static void hdm_disconnect(struct usb_interface *interface)
{
struct most_dev *mdev = usb_get_intfdata(interface);
+ /* hdm_request_netinfo() can still be called, and arms the timer */
+ timer_shutdown_sync(&mdev->link_stat_timer);
+ cancel_work_sync(&mdev->poll_work_obj);
+
mutex_lock(&mdev->io_mutex);
usb_set_intfdata(interface, NULL);
mdev->usb_device = NULL;
mutex_unlock(&mdev->io_mutex);
- timer_delete_sync(&mdev->link_stat_timer);
- cancel_work_sync(&mdev->poll_work_obj);
-
if (mdev->dci)
device_unregister(&mdev->dci->dev);
most_deregister_interface(&mdev->iface);
--
2.56.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-27 16:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-27 16:33 [PATCH] most: usb: don't use a NULL device on disconnect Greg Kroah-Hartman
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®