From: Arjan van de Ven Date: Mon, 22 Sep 2008 22:00:10 +0000 (-0700) Subject: usbmon: fix tiny race exposed by the fastboot patches X-Git-Tag: v2.6.28-rc1~254^2~60 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bb4e3b5ac81a9601775e62649038934acafa78e2;p=platform%2Fkernel%2Flinux-3.10.git usbmon: fix tiny race exposed by the fastboot patches usbmon registers the notifier chain, takes the bus lock and then goes to scan the existing devices for hooking up. Unfortunately, if usb_mon gets initialized while USB bus discovery is going on, it's possible that usbmon gets a notifier on one cpu (which runs without USB locks), and the scan is going on and also finds the new bus, resulting in a double sysfs registration, which then produces a WARNING. Pete Zaitcev did the bug diagnostics on this one Signed-off-by: Arjan van de Ven Acked-by: Pete Zaitcev Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/mon/mon_main.c b/drivers/usb/mon/mon_main.c index 442d807..5e0ab42 100644 --- a/drivers/usb/mon/mon_main.c +++ b/drivers/usb/mon/mon_main.c @@ -361,12 +361,12 @@ static int __init mon_init(void) } // MOD_INC_USE_COUNT(which_module?); - usb_register_notify(&mon_nb); mutex_lock(&usb_bus_list_lock); list_for_each_entry (ubus, &usb_bus_list, bus_list) { mon_bus_init(ubus); } + usb_register_notify(&mon_nb); mutex_unlock(&usb_bus_list_lock); return 0;