usb: hub: Fix RPM teardown on usb_disconnect
PATCH 1/1 usb: hub: Fix RPM teardown on usb_disconnect
On usb_disconnect, the free-ing of the device structure of usb_device is not well synchornized with the RPM subsystem, which leads to a possible use-after-free
Add proper device's handling for unregistering from the runtime PM to usb_disconnect
Reported-by [email protected]
Signed-off-by Deepak Sharma <[email protected]>
--- drivers/usb/core/hub.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/core/hub.c +6 -1
@@ -2329,8 +2329,13 @@ void usb_disconnect(struct usb_device **pdev)/* * Ensure that the pm runtime code knows that the USB device * is in the process of being disconnected. +* This is safe to do here, since all the code paths after +* here will lead to eventual deletion of the device */ -pm_runtime_barrier (&udev->dev); +pm_runtime_disable (&udev->dev); +pm_runtime_dont_use_autosuspend (&udev->dev); +pm_runtime_put_noidle (&udev->dev); +pm_runtime_set_suspended (&udev->dev);usb_lock_device (udev);
Signature · 1 line
2.51.0