All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] usb: misc: onboard_hub: Invert driver registration order
@ 2023-01-05 23:03 Matthias Kaehlcke
  2023-01-05 23:03 ` [PATCH 2/2] usb: misc: onboard_hub: Move 'attach' work to the driver Matthias Kaehlcke
  2023-01-06 15:32 ` [PATCH 1/2] usb: misc: onboard_hub: Invert driver registration order Greg Kroah-Hartman
  0 siblings, 2 replies; 9+ messages in thread
From: Matthias Kaehlcke @ 2023-01-05 23:03 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Johan Hovold, linux-usb, Stefan Wahren, Alexander Stein,
	Icenowy Zheng, Douglas Anderson, stable, linux-kernel,
	Matthias Kaehlcke, Ravi Chandra Sadineni

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: stable@vger.kernel.org
Fixes: 8bc063641ceb ("usb: misc: Add onboard_usb_hub driver")
Link: https://lore.kernel.org/lkml/Y6W00vQm3jfLflUJ@hovoldconsulting.com/T/#m0d64295f017942fd988f7c53425db302d61952b4
Reported-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---

 drivers/usb/misc/onboard_usb_hub.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/misc/onboard_usb_hub.c b/drivers/usb/misc/onboard_usb_hub.c
index 94e7966e199d..db0844b30bbd 100644
--- a/drivers/usb/misc/onboard_usb_hub.c
+++ b/drivers/usb/misc/onboard_usb_hub.c
@@ -433,13 +433,13 @@ static int __init onboard_hub_init(void)
 {
 	int ret;
 
-	ret = platform_driver_register(&onboard_hub_driver);
+	ret = usb_register_device_driver(&onboard_hub_usbdev_driver, THIS_MODULE);
 	if (ret)
 		return ret;
 
-	ret = usb_register_device_driver(&onboard_hub_usbdev_driver, THIS_MODULE);
+	ret = platform_driver_register(&onboard_hub_driver);
 	if (ret)
-		platform_driver_unregister(&onboard_hub_driver);
+		usb_deregister_device_driver(&onboard_hub_usbdev_driver);
 
 	return ret;
 }
-- 
2.39.0.314.g84b9a713c41-goog


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-01-10  1:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05 23:03 [PATCH 1/2] usb: misc: onboard_hub: Invert driver registration order Matthias Kaehlcke
2023-01-05 23:03 ` [PATCH 2/2] usb: misc: onboard_hub: Move 'attach' work to the driver Matthias Kaehlcke
2023-01-07 17:23   ` Stefan Wahren
2023-01-08 10:47     ` Stefan Wahren
2023-01-09 17:40       ` Matthias Kaehlcke
2023-01-09 20:19         ` Stefan Wahren
2023-01-10  1:07           ` Matthias Kaehlcke
2023-01-06 15:32 ` [PATCH 1/2] usb: misc: onboard_hub: Invert driver registration order Greg Kroah-Hartman
2023-01-06 16:13   ` Matthias Kaehlcke

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.