Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1324548
| From | Bjorn Helgaas <bhelgaas@google.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 1/3] PCI: Check device_attach() return value always |
| Date | 2016-02-02 20:30 +0100 |
| Message-ID | <qXOOe-7LC-17@gated-at.bofh.it> (permalink) |
| References | <qXOOd-7LC-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Previously we checked the device_attach() return value only when
CONFIG_BUG=y. That caused this warning in builds where CONFIG_BUG is not
set:
drivers/pci/bus.c:237:6: warning: variable 'retval' set but not used [-Wunused-but-set-variable]
Check the return value of device_attach() always and clean up after
failure.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/bus.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 89b3bef..f2187d4 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -291,7 +291,12 @@ void pci_bus_add_device(struct pci_dev *dev)
dev->match_driver = true;
retval = device_attach(&dev->dev);
- WARN_ON(retval < 0);
+ if (retval < 0) {
+ dev_warn(&dev->dev, "device attach failed (%d)\n", retval);
+ pci_proc_detach_device(dev);
+ pci_remove_sysfs_dev_files(dev);
+ return;
+ }
dev->is_added = 1;
}
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/3] PCI: Clean up warnings Bjorn Helgaas <bhelgaas@google.com> - 2016-02-02 20:30 +0100 [PATCH 1/3] PCI: Check device_attach() return value always Bjorn Helgaas <bhelgaas@google.com> - 2016-02-02 20:30 +0100 [PATCH 3/3] PCI/PME: Restructure pcie_pme_suspend() to prevent compiler warning Bjorn Helgaas <bhelgaas@google.com> - 2016-02-02 20:30 +0100 [PATCH 2/3] PCI/PME: Remove redundant port lookup Bjorn Helgaas <bhelgaas@google.com> - 2016-02-02 20:30 +0100 Re: [PATCH 0/3] PCI: Clean up warnings "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-02-03 02:40 +0100 Re: [PATCH 0/3] PCI: Clean up warnings Bjorn Helgaas <helgaas@kernel.org> - 2016-02-05 23:40 +0100
csiph-web