USB: g_hid: unregister platform driver on probe/usb_composite_register errors
authorPeter Korsgaard <peter.korsgaard@barco.com>
Mon, 26 Apr 2010 08:05:06 +0000 (10:05 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 20 May 2010 20:21:40 +0000 (13:21 -0700)
Otherwise reloads will fail.

Signed-off-by: Peter Korsgaard <peter.korsgaard@barco.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/gadget/hid.c

index b77e97754b4a6ac018a44080aaa9a2bff58df26f..775722686ed85143cd89d159cc4e61385b64417f 100644 (file)
@@ -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);