mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arjan van de Ven <arjan@infradead.org>
To: zaitcev@redhat.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] usbmon: fix tiny race exposed by the fastboot patches
Date: Sat, 13 Sep 2008 12:48:58 -0700	[thread overview]
Message-ID: <20080913124858.529fb8e2@infradead.org> (raw)


From: Arjan van de Ven <arjan@linux.intel.com>
Subject: [PATCH] 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 <arjan@linux.intel.com>
---
 drivers/usb/mon/mon_main.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

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;
 
-- 
1.5.5.1



-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org

             reply	other threads:[~2008-09-13 19:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-13 19:48 Arjan van de Ven [this message]
2008-09-13 20:05 ` Pete Zaitcev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080913124858.529fb8e2@infradead.org \
    --to=arjan@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zaitcev@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome