From: Dmitry Torokhov <dtor_core@ameritech.net>
To: Greg KH <greg@kroah.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Patrick Mochel <mochel@digitalimplant.org>
Subject: [PATCH 4/4] Driver core: bus_rescan_devices improper locking
Date: Sat, 30 Oct 2004 03:29:18 -0500 [thread overview]
Message-ID: <200410300329.20539.dtor_core@ameritech.net> (raw)
In-Reply-To: <200410300328.48554.dtor_core@ameritech.net>
===================================================================
ChangeSet@1.1958, 2004-10-30 03:13:25-05:00, dtor_core@ameritech.net
Driver core: bus_rescan_devices() should take write lock to guarantee
that 2 threads will not probe same device and therefore
can not be implemented with bus_for_each_dev().
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
bus.c | 24 +++++++++++-------------
1 files changed, 11 insertions(+), 13 deletions(-)
===================================================================
diff -Nru a/drivers/base/bus.c b/drivers/base/bus.c
--- a/drivers/base/bus.c 2004-10-30 03:15:58 -05:00
+++ b/drivers/base/bus.c 2004-10-30 03:15:58 -05:00
@@ -571,18 +571,6 @@
}
-/* Helper for bus_rescan_devices's iter */
-static int bus_rescan_devices_helper(struct device *dev, void *data)
-{
- int *count = data;
-
- if (!dev->driver && device_attach(dev))
- (*count)++;
-
- return 0;
-}
-
-
/**
* bus_rescan_devices - rescan devices on the bus for possible drivers
* @bus: the bus to scan.
@@ -594,9 +582,19 @@
*/
int bus_rescan_devices(struct bus_type * bus)
{
+ struct device *dev;
int count = 0;
- bus_for_each_dev(bus, NULL, &count, bus_rescan_devices_helper);
+ if (!(bus = get_bus(bus)))
+ return 0;
+
+ down_write(&bus->subsys.rwsem);
+ list_for_each_entry(dev, &bus->devices.list, bus_list) {
+ if (!dev->driver && device_attach(dev))
+ count++;
+ }
+ up_write(&bus->subsys.rwsem);
+ put_bus(bus);
return count;
}
next prev parent reply other threads:[~2004-10-30 8:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-29 18:57 [PATCH 2/4] Driver core: add driver_probe_device Dmitry Torokhov
2004-10-29 20:22 ` Greg KH
2004-10-30 8:26 ` Dmitry Torokhov
2004-10-30 8:27 ` [PATCH 1/4] Driver core: add driver symlink to device Dmitry Torokhov
2004-10-30 8:28 ` [PATCH 2/4] Driver core: add drvctl device attribute Dmitry Torokhov
2004-10-30 8:28 ` [PATCH 3/4] Driver core: add bind_mode device/driver attributes Dmitry Torokhov
2004-10-30 8:29 ` Dmitry Torokhov [this message]
2004-11-01 22:43 ` [PATCH 1/4] Driver core: add driver symlink to device Greg KH
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=200410300329.20539.dtor_core@ameritech.net \
--to=dtor_core@ameritech.net \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mochel@digitalimplant.org \
/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