Commit cc74d96f47b0d916840f92092595e3be9731e047
1 parent
93d74463d0
Exists in
master
and in
7 other branches
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
drivers/pci/bus.c
... | ... | @@ -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"); |
include/linux/pci.h