Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCIE: check and return bus_register errors

Have pcie_port_bus_register() notice and return errors.
Mark it __must_check so that its caller(s) must check its return value.

Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Randy Dunlap and committed by
Greg Kroah-Hartman
20d51660 6397c75c

+11 -5
+1 -1
drivers/pci/pcie/portdrv.h
··· 39 39 extern int pcie_port_device_resume(struct pci_dev *dev); 40 40 #endif 41 41 extern void pcie_port_device_remove(struct pci_dev *dev); 42 - extern void pcie_port_bus_register(void); 42 + extern int pcie_port_bus_register(void); 43 43 extern void pcie_port_bus_unregister(void); 44 44 45 45 #endif /* _PORTDRV_H_ */
+3 -2
drivers/pci/pcie/portdrv_core.c
··· 6 6 * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com) 7 7 */ 8 8 9 + #include <linux/compiler.h> 9 10 #include <linux/module.h> 10 11 #include <linux/pci.h> 11 12 #include <linux/kernel.h> ··· 403 402 pci_disable_msi(dev); 404 403 } 405 404 406 - void pcie_port_bus_register(void) 405 + int __must_check pcie_port_bus_register(void) 407 406 { 408 - bus_register(&pcie_port_bus_type); 407 + return bus_register(&pcie_port_bus_type); 409 408 } 410 409 411 410 void pcie_port_bus_unregister(void)
+7 -2
drivers/pci/pcie/portdrv_pci.c
··· 129 129 130 130 static int __init pcie_portdrv_init(void) 131 131 { 132 - int retval = 0; 132 + int retval; 133 133 134 - pcie_port_bus_register(); 134 + retval = pcie_port_bus_register(); 135 + if (retval) { 136 + printk(KERN_WARNING "PCIE: bus_register error: %d\n", retval); 137 + goto out; 138 + } 135 139 retval = pci_register_driver(&pcie_portdrv); 136 140 if (retval) 137 141 pcie_port_bus_unregister(); 142 + out: 138 143 return retval; 139 144 } 140 145