From da01c7a49bfc94dbfa66af5ca5e1063b10bc6a10 Mon Sep 17 00:00:00 2001 From: Peter Korsgaard Date: Mon, 26 Apr 2010 10:05:06 +0200 Subject: [PATCH] USB: g_hid: unregister platform driver on probe/usb_composite_register errors Otherwise reloads will fail. Signed-off-by: Peter Korsgaard Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/hid.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/hid.c b/drivers/usb/gadget/hid.c index b77e97754b4a..775722686ed8 100644 --- a/drivers/usb/gadget/hid.c +++ b/drivers/usb/gadget/hid.c @@ -275,8 +275,18 @@ MODULE_LICENSE("GPL"); static int __init hidg_init(void) { - platform_driver_probe(&hidg_plat_driver, hidg_plat_driver_probe); - return usb_composite_register(&hidg_driver); + int status; + + status = platform_driver_probe(&hidg_plat_driver, + hidg_plat_driver_probe); + if (status < 0) + return status; + + status = usb_composite_register(&hidg_driver); + if (status < 0) + platform_driver_unregister(&hidg_plat_driver); + + return status; } module_init(hidg_init); -- 2.20.1