Skip to content

Commit

Permalink
PCI: Check device_attach() return value always
Browse files Browse the repository at this point in the history
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>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Bjorn Helgaas committed Feb 5, 2016
1 parent 92e963f commit ab1a187
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/pci/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit ab1a187

Please sign in to comment.