Commit f4053874 authored by Sergei Shtylyov's avatar Sergei Shtylyov Committed by Greg Kroah-Hartman

USB: MUSB: fix kernel WARNING/oops when unloading module in OTG mode

Since commit 461972d8 (musb_core: don't call
musb_platform_exit() twice), unloading the driver module results in a WARNING
"kobject: '(null)' (c73de788): is not initialized, yet kobject_put() is being
called." (or even kernel oops) on e.g. DaVincis, though only in the OTG mode.
There exists dubious and unbalanced put_device() call in musb_free() which
takes place only in the OTG mode.  As this commit caused musb_platform_exit()
to be called (and so unregister the NOP transceiver) before this put_device()
call, this function references already freed memory.

On the other hand, all the glue layers miss the otg_put_transceiver() call,
complementary to the otg_get_transceiver() call that they do.  So, I think
the solution is to get rid of the strange put_device() call, and instead
call otg_put_transceiver() in the glue layers...
Signed-off-by: default avatarSergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: stable <stable@kernel.org>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 230f7ede
...@@ -397,5 +397,6 @@ int musb_platform_exit(struct musb *musb) ...@@ -397,5 +397,6 @@ int musb_platform_exit(struct musb *musb)
gpio_free(musb->config->gpio_vrsel); gpio_free(musb->config->gpio_vrsel);
otg_put_transceiver(musb->xceiv);
return 0; return 0;
} }
...@@ -446,6 +446,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data) ...@@ -446,6 +446,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data)
fail: fail:
clk_disable(musb->clock); clk_disable(musb->clock);
otg_put_transceiver(musb->xceiv);
usb_nop_xceiv_unregister(); usb_nop_xceiv_unregister();
return -ENODEV; return -ENODEV;
} }
...@@ -496,6 +497,7 @@ int musb_platform_exit(struct musb *musb) ...@@ -496,6 +497,7 @@ int musb_platform_exit(struct musb *musb)
clk_disable(musb->clock); clk_disable(musb->clock);
otg_put_transceiver(musb->xceiv);
usb_nop_xceiv_unregister(); usb_nop_xceiv_unregister();
return 0; return 0;
......
...@@ -1926,10 +1926,6 @@ static void musb_free(struct musb *musb) ...@@ -1926,10 +1926,6 @@ static void musb_free(struct musb *musb)
dma_controller_destroy(c); dma_controller_destroy(c);
} }
#ifdef CONFIG_USB_MUSB_OTG
put_device(musb->xceiv->dev);
#endif
#ifdef CONFIG_USB_MUSB_HDRC_HCD #ifdef CONFIG_USB_MUSB_HDRC_HCD
usb_put_hcd(musb_to_hcd(musb)); usb_put_hcd(musb_to_hcd(musb));
#else #else
......
...@@ -320,5 +320,6 @@ int musb_platform_exit(struct musb *musb) ...@@ -320,5 +320,6 @@ int musb_platform_exit(struct musb *musb)
musb_platform_suspend(musb); musb_platform_suspend(musb);
otg_put_transceiver(musb->xceiv);
return 0; return 0;
} }
...@@ -1152,6 +1152,8 @@ int __init musb_platform_init(struct musb *musb, void *board_data) ...@@ -1152,6 +1152,8 @@ int __init musb_platform_init(struct musb *musb, void *board_data)
if (ret < 0) { if (ret < 0) {
if (sync) if (sync)
iounmap(sync); iounmap(sync);
otg_put_transceiver(musb->xceiv);
usb_nop_xceiv_unregister(); usb_nop_xceiv_unregister();
} }
return ret; return ret;
...@@ -1166,6 +1168,8 @@ int musb_platform_exit(struct musb *musb) ...@@ -1166,6 +1168,8 @@ int musb_platform_exit(struct musb *musb)
musb->board_set_power(0); musb->board_set_power(0);
iounmap(musb->sync_va); iounmap(musb->sync_va);
otg_put_transceiver(musb->xceiv);
usb_nop_xceiv_unregister(); usb_nop_xceiv_unregister();
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment