Commit cc74d96f47b0d916840f92092595e3be9731e047

Authored by Greg Kroah-Hartman
1 parent 93d74463d0

PCI: fix issue with busses registering multiple times in sysfs

PCI busses can be registered multiple times, so we need to detect if we
have registered our bus structure in sysfs already.  If so, don't do it
again.

Thanks to Guennadi Liakhovetski <g.liakhovetski@gmx.de> for reporting
the problem, and to Linus for poking me to get me to believe that it was
a real problem.

Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Showing 2 changed files with 6 additions and 1 deletions Side-by-side Diff

... ... @@ -143,14 +143,18 @@
143 143 /* register the bus with sysfs as the parent is now
144 144 * properly registered. */
145 145 child_bus = dev->subordinate;
  146 + if (child_bus->is_added)
  147 + continue;
146 148 child_bus->dev.parent = child_bus->bridge;
147 149 retval = device_register(&child_bus->dev);
148 150 if (retval)
149 151 dev_err(&dev->dev, "Error registering pci_bus,"
150 152 " continuing...\n");
151   - else
  153 + else {
  154 + child_bus->is_added = 1;
152 155 retval = device_create_file(&child_bus->dev,
153 156 &dev_attr_cpuaffinity);
  157 + }
154 158 if (retval)
155 159 dev_err(&dev->dev, "Error creating cpuaffinity"
156 160 " file, continuing...\n");
... ... @@ -278,6 +278,7 @@
278 278 struct device dev;
279 279 struct bin_attribute *legacy_io; /* legacy I/O for this bus */
280 280 struct bin_attribute *legacy_mem; /* legacy mem */
  281 + unsigned int is_added:1;
281 282 };
282 283  
283 284 #define pci_bus_b(n) list_entry(n, struct pci_bus, node)