[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241018141337.316807-1-danielgeorgem@chromium.org>
Date: Fri, 18 Oct 2024 14:13:37 +0000
From: George-Daniel Matei <danielgeorgem@...omium.org>
To: "David S. Miller" <davem@...emloft.net>,
Hayes Wang <hayeswang@...ltek.com>,
Heiner Kallweit <hkallweit1@...il.com>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Douglas Anderson <dianders@...omium.org>,
Grant Grundler <grundler@...omium.org>,
George-Daniel Matei <danielgeorgem@...omium.org>
Cc: linux-usb@...r.kernel.org,
netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] r8152: fix deadlock in usb reset during resume
rtl8152_system_resume() issues a synchronous usb reset if the device is
inaccessible. __rtl8152_set_mac_address() is called via
rtl8152_post_reset() and it tries to take the same mutex that was already
taken in rtl8152_resume(). Move the call to reset usb in rtl8152_resume()
outside mutex protection.
Signed-off-by: George-Daniel Matei <danielgeorgem@...omium.org>
---
drivers/net/usb/r8152.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index a5612c799f5e..69d66ce7a5c5 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -8564,19 +8564,6 @@ static int rtl8152_system_resume(struct r8152 *tp)
usb_submit_urb(tp->intr_urb, GFP_NOIO);
}
- /* If the device is RTL8152_INACCESSIBLE here then we should do a
- * reset. This is important because the usb_lock_device_for_reset()
- * that happens as a result of usb_queue_reset_device() will silently
- * fail if the device was suspended or if too much time passed.
- *
- * NOTE: The device is locked here so we can directly do the reset.
- * We don't need usb_lock_device_for_reset() because that's just a
- * wrapper over device_lock() and device_resume() (which calls us)
- * does that for us.
- */
- if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
- usb_reset_device(tp->udev);
-
return 0;
}
@@ -8681,6 +8668,19 @@ static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
mutex_unlock(&tp->control);
+ /* If the device is RTL8152_INACCESSIBLE here then we should do a
+ * reset. This is important because the usb_lock_device_for_reset()
+ * that happens as a result of usb_queue_reset_device() will silently
+ * fail if the device was suspended or if too much time passed.
+ *
+ * NOTE: The device is locked here so we can directly do the reset.
+ * We don't need usb_lock_device_for_reset() because that's just a
+ * wrapper over device_lock() and device_resume() (which calls us)
+ * does that for us.
+ */
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
+ usb_reset_device(tp->udev);
+
return ret;
}
--
2.47.0.rc1.288.g06298d1525-goog
Powered by blists - more mailing lists