diff mbox series

[2/2] USB: max3421: Fix scheduling while atomic in max3421_remove()

Message ID CABrMTjfEqJhUyDKX8UvrZOFFFpaoqEM9WM7Jfso09pXYSA7jtA@mail.gmail.com (mailing list archive)
State New
Headers show
Series [1/2] USB: max3421: Improve retransmit handling for NAK responses | expand

Commit Message

Matt Lee Feb. 10, 2025, 2:06 p.m. UTC
A bug in `max3421_remove()` caused a "scheduling while atomic" crash when
`kthread_stop()` was called while holding a spinlock.

This patch ensures that `kthread_stop()` is called outside the spinlock,
fixing the crash and improving system stability when unloading the driver.

Signed-off-by: Matt Lee <matt@oscium.com>
---
 drivers/usb/host/max3421-hcd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/usb/host/max3421-hcd.c b/drivers/usb/host/max3421-hcd.c
index abcdef0..1234567 100644
--- a/drivers/usb/host/max3421-hcd.c
+++ b/drivers/usb/host/max3421-hcd.c
@@ -1936,11 +1945,10 @@  max3421_remove(struct spi_device *spi)
        usb_remove_hcd(hcd);

        spin_lock_irqsave(&max3421_hcd->lock, flags);
+       spin_unlock_irqrestore(&max3421_hcd->lock, flags);

        kthread_stop(max3421_hcd->spi_thread);

-       spin_unlock_irqrestore(&max3421_hcd->lock, flags);
-
        free_irq(spi->irq, hcd);

        usb_put_hcd(hcd);