diff mbox

[1/6] usb: chipidea: usbmisc: unset global varibale usbmisc on driver remove

Message ID 1352894137-2050-2-git-send-email-m.grzeschik@pengutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Grzeschik Nov. 14, 2012, 11:55 a.m. UTC
From: Marc Kleine-Budde <mkl@pengutronix.de>

While there fix a potential race condition, first set usbmisc, then call
usbmisc_set_ops().

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
 drivers/usb/chipidea/usbmisc_imx6q.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Alexander Shishkin Nov. 14, 2012, 1:22 p.m. UTC | #1
Michael Grzeschik <m.grzeschik@pengutronix.de> writes:

> From: Marc Kleine-Budde <mkl@pengutronix.de>
>
> While there fix a potential race condition, first set usbmisc, then call
> usbmisc_set_ops().

This should be really two separate patches, both of which could use
more elaborate commit messages. That is, if you unset variable, what
kind of scenario it prevents, what exactly is the potential race
condition, etc. Saves time for everybody.

>
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> ---
>  drivers/usb/chipidea/usbmisc_imx6q.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

I'd also move the renaming patch in front of everything else, but that's
up to you.

Regards,
--
Alex
diff mbox

Patch

diff --git a/drivers/usb/chipidea/usbmisc_imx6q.c b/drivers/usb/chipidea/usbmisc_imx6q.c
index 416e3fc..edc0edd 100644
--- a/drivers/usb/chipidea/usbmisc_imx6q.c
+++ b/drivers/usb/chipidea/usbmisc_imx6q.c
@@ -116,14 +116,14 @@  static int __devinit usbmisc_imx6q_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	usbmisc = data;
 	ret = usbmisc_set_ops(&imx6q_usbmisc_ops);
 	if (ret) {
+		usbmisc = NULL;
 		clk_disable_unprepare(data->clk);
 		return ret;
 	}
 
-	usbmisc = data;
-
 	return 0;
 }
 
@@ -131,6 +131,7 @@  static int __devexit usbmisc_imx6q_remove(struct platform_device *pdev)
 {
 	usbmisc_unset_ops(&imx6q_usbmisc_ops);
 	clk_disable_unprepare(usbmisc->clk);
+	usbmisc = NULL;
 	return 0;
 }