From: Hollis Blanchard <hollisb@us.ibm.com>
To: mochel@digitalimplant.org
Cc: linux-kernel@vger.kernel.org, Greg KH <greg@kroah.com>
Subject: (driver model) bus kset list manipulation bug
Date: Thu, 22 Jan 2004 13:38:53 -0600 [thread overview]
Message-ID: <401026CD.2030600@us.ibm.com> (raw)
Hi Patrick, I know you've passed maintainership of the driver model code
on, but I was hoping I could jog your memory.
I've found a bug in drivers/base/bus.c, where the bus_type.devices.list
is treated as a list of device structs. bus_type.devices is a kset
though, so devices.list should contain kobjects rather than devices.
Here is the diff I've come up with:
===== drivers/base/bus.c 1.52 vs edited =====
--- 1.52/drivers/base/bus.c Tue Sep 30 10:59:35 2003
+++ edited/drivers/base/bus.c Thu Jan 22 11:22:15 2004
@@ -18,7 +18,7 @@
#include "base.h"
#include "power/power.h"
-#define to_dev(node) container_of(node,struct device,bus_list)
+#define to_dev(node) container_of(node,struct device,kobj.entry)
#define to_drv(node) container_of(node,struct device_driver,kobj.entry)
#define to_bus_attr(_attr) container_of(_attr,struct bus_attribute,attr)
@@ -164,7 +164,7 @@
if (!(bus = get_bus(bus)))
return -EINVAL;
- head = start ? &start->bus_list : &bus->devices.list;
+ head = start ? &start->kobj.entry : &bus->devices.list;
down_read(&bus->subsys.rwsem);
list_for_each(entry,head) {
@@ -337,7 +337,7 @@
return;
list_for_each(entry,&bus->devices.list) {
- struct device * dev = container_of(entry,struct
device,bus_list);
+ struct device * dev = to_dev(entry);
if (!dev->driver) {
error = bus_match(dev,drv);
if (error && (error != -ENODEV))
@@ -405,7 +405,7 @@
if (bus) {
down_write(&dev->bus->subsys.rwsem);
pr_debug("bus %s: add device %s\n",bus->name,dev->bus_id);
- list_add_tail(&dev->bus_list,&dev->bus->devices.list);
+ list_add_tail(&dev->kobj.entry,&dev->bus->devices.list);
device_attach(dev);
up_write(&dev->bus->subsys.rwsem);
sysfs_create_link(&bus->devices.kobj,&dev->kobj,dev->bus_id);
The first hunk you can see is symmetrical with to_drv just below. The
next hunk, to bus_for_each_dev, makes it match up with bus_for_each_drv
(I take this as evidence that I'm right). The next hunk, in
driver_attach, can be compared with device_attach and again you'll see
the symmetry (to_drv/to_dev).
The last hunk in bus_add_device is where we were inserting the
device.bus_list rather than devices.kobject.entry into the kset.
These are the only 3 users of the devices kset that I could find.
Unfortunately when I make these changes I get a panic like so:
bus_match +0x28
driver_attach +0xa0
bus_add_driver +0xdc
driver_register +0x38
pci_register_driver +0x6c
serial8250_pci_init +0x28
I'm having a bit of trouble figuring out what went wrong. Are there
other users of bus_type.devices that I've missed and need updating? Thanks!
--
Hollis Blanchard
IBM Linux Technology Center
next reply other threads:[~2004-01-22 19:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-22 19:38 Hollis Blanchard [this message]
2004-01-22 23:35 ` (driver model) bus kset list manipulation bug Hollis Blanchard
2004-01-27 23:31 ` Hollis Blanchard
2004-01-30 20:49 ` Hollis Blanchard
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=401026CD.2030600@us.ibm.com \
--to=hollisb@us.ibm.com \
--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