[PATCH 10/14] usb: dwc2: host: free status_buf on hcd de-init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



status_buf needs to be freed in dwc2_hcd_remove().

Signed-off-by: Gregory Herrero <gregory.herrero@xxxxxxxxx>
---
 drivers/usb/dwc2/hcd.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index af4e4a2..41c00e9 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -3141,7 +3141,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq)
 	 */
 	retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
 	if (retval < 0)
-		goto error3;
+		goto error4;
 
 	device_wakeup_enable(hcd->self.controller);
 
@@ -3151,6 +3151,14 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq)
 
 	return 0;
 
+error4:
+	if (hsotg->core_params->dma_enable > 0)
+		dma_free_coherent(hsotg->dev,
+				  DWC2_HCD_STATUS_BUF_SIZE,
+				  hsotg->status_buf,
+				  hsotg->status_buf_dma);
+	else
+		kfree(hsotg->status_buf);
 error3:
 	dwc2_hcd_release(hsotg);
 error2:
@@ -3191,6 +3199,15 @@ void dwc2_hcd_remove(struct dwc2_hsotg *hsotg)
 
 	usb_remove_hcd(hcd);
 	hsotg->priv = NULL;
+
+	if (hsotg->core_params->dma_enable > 0)
+		dma_free_coherent(hsotg->dev,
+				  DWC2_HCD_STATUS_BUF_SIZE,
+				  hsotg->status_buf,
+				  hsotg->status_buf_dma);
+	else
+		kfree(hsotg->status_buf);
+
 	dwc2_hcd_release(hsotg);
 	usb_put_hcd(hcd);
 
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux