Skip to content

Commit e585435

Browse files
Matthias Kaehlckegregkh
authored andcommitted
usb: misc: onboard_hub: Invert driver registration order
The onboard_hub 'driver' consists of two drivers, a platform driver and a USB driver. Currently when the onboard hub driver is initialized it first registers the platform driver, then the USB driver. This results in a race condition when the 'attach' work is executed, which is scheduled when the platform device is probed. The purpose of fhe 'attach' work is to bind elegible USB hub devices to the onboard_hub USB driver. This fails if the work runs before the USB driver has been registered. Register the USB driver first, then the platform driver. This increases the chances that the onboard_hub USB devices are probed before their corresponding platform device, which the USB driver tries to locate in _probe(). The driver already handles this situation and defers probing if the onboard hub platform device doesn't exist yet. Cc: [email protected] Fixes: 8bc0636 ("usb: misc: Add onboard_usb_hub driver") Link: https://lore.kernel.org/lkml/[email protected]/T/#m0d64295f017942fd988f7c53425db302d61952b4 Reported-by: Alexander Stein <[email protected]> Signed-off-by: Matthias Kaehlcke <[email protected]> Tested-by: Stefan Wahren <[email protected]> Link: https://lore.kernel.org/r/20230110172954.v2.1.I75494ebee7027a50235ce4b1e930fa73a578fbe2@changeid Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent fac4b86 commit e585435

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/usb/misc/onboard_usb_hub.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,13 +433,13 @@ static int __init onboard_hub_init(void)
433433
{
434434
int ret;
435435

436-
ret = platform_driver_register(&onboard_hub_driver);
436+
ret = usb_register_device_driver(&onboard_hub_usbdev_driver, THIS_MODULE);
437437
if (ret)
438438
return ret;
439439

440-
ret = usb_register_device_driver(&onboard_hub_usbdev_driver, THIS_MODULE);
440+
ret = platform_driver_register(&onboard_hub_driver);
441441
if (ret)
442-
platform_driver_unregister(&onboard_hub_driver);
442+
usb_deregister_device_driver(&onboard_hub_usbdev_driver);
443443

444444
return ret;
445445
}

0 commit comments

Comments
 (0)