Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: g_hid: unregister platform driver on probe/usb_composite_register errors

Otherwise reloads will fail.

Signed-off-by: Peter Korsgaard <peter.korsgaard@barco.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Peter Korsgaard and committed by
Greg Kroah-Hartman
da01c7a4 fe662b43

+12 -2
+12 -2
drivers/usb/gadget/hid.c
··· 275 275 276 276 static int __init hidg_init(void) 277 277 { 278 - platform_driver_probe(&hidg_plat_driver, hidg_plat_driver_probe); 279 - return usb_composite_register(&hidg_driver); 278 + int status; 279 + 280 + status = platform_driver_probe(&hidg_plat_driver, 281 + hidg_plat_driver_probe); 282 + if (status < 0) 283 + return status; 284 + 285 + status = usb_composite_register(&hidg_driver); 286 + if (status < 0) 287 + platform_driver_unregister(&hidg_plat_driver); 288 + 289 + return status; 280 290 } 281 291 module_init(hidg_init); 282 292