Skip to contentSkip to conversation

usb: host: ehci-atmel: stop clocks before releasing HCD

PATCH Superseded Hongyan Xu 3 participants 4 messages Aug 6

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Hongyan Xu

author
#0 lore raw

PATCH 1/1 usb: host: ehci-atmel: stop clocks before releasing HCD

usb_put_hcd() drops the driver's HCD reference and can free the HCD and its private data. The remove callback then calls atmel_stop_ehci(), which obtains that HCD from platform data and dereferences its private data to disable the clocks.

Stop the controller clocks before dropping the HCD reference so that atmel_stop_ehci() cannot access an already freed HCD.

Fixes 501c9c0802d9 ("USB: at91: Add USB EHCI driver for at91sam9g45 series")
---
 drivers/usb/host/ehci-atmel.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/host/ehci-atmel.c +1 -2
index 65747270fd88..bcd56f888ec9 100644
@@ -177,9 +177,8 @@ static void ehci_atmel_drv_remove(struct platform_device *pdev)
 	struct usb_hcd *hcd = platform_get_drvdata(pdev);
 
 	usb_remove_hcd(hcd);
-	usb_put_hcd(hcd);
-
 	atmel_stop_ehci(pdev);
+	usb_put_hcd(hcd);
 }
 
 static int __maybe_unused ehci_atmel_drv_suspend(struct device *dev)
Signature · 1 line
2.50.1.windows.1
#1 lore raw
Quoted 5 lines · Hongyan Xu

usb_put_hcd() drops the driver's HCD reference and can free the HCD and its private data. The remove callback then calls atmel_stop_ehci(), which obtains that HCD from platform data and dereferences its private data to disable the clocks.

Quoted 8 lines

Stop the controller clocks before dropping the HCD reference so that atmel_stop_ehci() cannot access an already freed HCD.

Fixes 501c9c0802d9 ("USB: at91: Add USB EHCI driver for at91sam9g45 series")
---
 drivers/usb/host/ehci-atmel.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

You just sent a bunch of obviously-llm-helped patches without properly attributing that. Please resend new versions with the correct information, AND correctly cc: the stable tree for when you have Fixes:
tags like this.

thanks,

greg k-h

#2 lore raw
In reply to Hongyan Xu
Quoted 33 lines · Hongyan Xu

usb_put_hcd() drops the driver's HCD reference and can free the HCD and its private data. The remove callback then calls atmel_stop_ehci(), which obtains that HCD from platform data and dereferences its private data to disable the clocks.

Stop the controller clocks before dropping the HCD reference so that atmel_stop_ehci() cannot access an already freed HCD.

Fixes 501c9c0802d9 ("USB: at91: Add USB EHCI driver for at91sam9g45 series")
---
 drivers/usb/host/ehci-atmel.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/host/ehci-atmel.c +1 -2
index 65747270fd88..bcd56f888ec9 100644
@@ -177,9 +177,8 @@ static void ehci_atmel_drv_remove(struct platform_device *pdev)
 	struct usb_hcd *hcd = platform_get_drvdata(pdev);
 
 	usb_remove_hcd(hcd);
-	usb_put_hcd(hcd);
-
 	atmel_stop_ehci(pdev);
+	usb_put_hcd(hcd);
 }
 
 static int __maybe_unused ehci_atmel_drv_suspend(struct device *dev)
Signature · 1 line
2.50.1.windows.1

How was this tested?

maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Hongyan Xu
Quoted 11 lines · Hongyan Xu

usb_put_hcd() drops the driver's HCD reference and can free the HCD and its private data. The remove callback then calls atmel_stop_ehci(), which obtains that HCD from platform data and dereferences its private data to disable the clocks.

Stop the controller clocks before dropping the HCD reference so that atmel_stop_ehci() cannot access an already freed HCD.

Fixes 501c9c0802d9 ("USB: at91: Add USB EHCI driver for at91sam9g45 series")

---

Quoted 22 lines
 drivers/usb/host/ehci-atmel.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/host/ehci-atmel.c +1 -2
index 65747270fd88..bcd56f888ec9 100644
@@ -177,9 +177,8 @@ static void ehci_atmel_drv_remove(struct platform_device *pdev)
 	struct usb_hcd *hcd = platform_get_drvdata(pdev);
 
 	usb_remove_hcd(hcd);
-	usb_put_hcd(hcd);
-
 	atmel_stop_ehci(pdev);
+	usb_put_hcd(hcd);
 }
 
 static int __maybe_unused ehci_atmel_drv_suspend(struct device *dev)
Signature · 1 line
2.50.1.windows.1