linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] usb: dwc2: Add missing cleanups when usb_add_gadget_udc() fails
@ 2020-07-27 17:38 Martin Blumenstingl
  2020-07-27 19:56 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Blumenstingl @ 2020-07-27 17:38 UTC (permalink / raw)
  To: hminas, gregkh, linux-usb
  Cc: linux-kernel, marex, stable, Martin Blumenstingl

Call dwc2_debugfs_exit() and dwc2_hcd_remove() (if the HCD was enabled
earlier) when usb_add_gadget_udc() has failed. This ensures that the
debugfs entries created by dwc2_debugfs_init() as well as the HCD are
cleaned up in the error path.

Fixes: 207324a321a866 ("usb: dwc2: Postponed gadget registration to the udc class driver")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
Changes since v2 at [1]:
- add #if around the new label and it's code to prevent the following
  warning found by the Kernel test robot:
    unused label 'error_debugfs' [-Wunused-label]

Changes since v1 at [0]
- also cleanup the HCD as suggested by Minas (thank you!)
- updated the subject accordingly


[0] https://patchwork.kernel.org/patch/11631381/
[1] https://patchwork.kernel.org/patch/11642957/


 drivers/usb/dwc2/platform.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index cb8ddbd53718..b74099764b2d 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -583,12 +583,19 @@ static int dwc2_driver_probe(struct platform_device *dev)
 		retval = usb_add_gadget_udc(hsotg->dev, &hsotg->gadget);
 		if (retval) {
 			dwc2_hsotg_remove(hsotg);
-			goto error_init;
+			goto error_debugfs;
 		}
 	}
 #endif /* CONFIG_USB_DWC2_PERIPHERAL || CONFIG_USB_DWC2_DUAL_ROLE */
 	return 0;
 
+#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \
+	IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
+error_debugfs:
+	dwc2_debugfs_exit(hsotg);
+	if (hsotg->hcd_enabled)
+		dwc2_hcd_remove(hsotg);
+#endif
 error_init:
 	if (hsotg->params.activate_stm_id_vb_detection)
 		regulator_disable(hsotg->usb33d);
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] usb: dwc2: Add missing cleanups when usb_add_gadget_udc() fails
  2020-07-27 17:38 [PATCH v3] usb: dwc2: Add missing cleanups when usb_add_gadget_udc() fails Martin Blumenstingl
@ 2020-07-27 19:56 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2020-07-27 19:56 UTC (permalink / raw)
  To: Martin Blumenstingl; +Cc: hminas, linux-usb, linux-kernel, marex, stable

On Mon, Jul 27, 2020 at 07:38:01PM +0200, Martin Blumenstingl wrote:
> Call dwc2_debugfs_exit() and dwc2_hcd_remove() (if the HCD was enabled
> earlier) when usb_add_gadget_udc() has failed. This ensures that the
> debugfs entries created by dwc2_debugfs_init() as well as the HCD are
> cleaned up in the error path.
> 
> Fixes: 207324a321a866 ("usb: dwc2: Postponed gadget registration to the udc class driver")
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---
> Changes since v2 at [1]:
> - add #if around the new label and it's code to prevent the following
>   warning found by the Kernel test robot:
>     unused label 'error_debugfs' [-Wunused-label]
> 
> Changes since v1 at [0]
> - also cleanup the HCD as suggested by Minas (thank you!)
> - updated the subject accordingly
> 
> 
> [0] https://patchwork.kernel.org/patch/11631381/
> [1] https://patchwork.kernel.org/patch/11642957/


<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-27 19:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-27 17:38 [PATCH v3] usb: dwc2: Add missing cleanups when usb_add_gadget_udc() fails Martin Blumenstingl
2020-07-27 19:56 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).