From: "Randy.Dunlap" <rdunlap@xenotime.net>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, greg@kroah.com, davej@codemonkey.org.uk
Subject: [PATCH] PCIE: check and return bus_register errors
Date: Sat, 8 Jul 2006 22:58:25 -0700 [thread overview]
Message-ID: <20060708225825.0c1fac16.rdunlap@xenotime.net> (raw)
In-Reply-To: <20060707171015.688e4011.akpm@osdl.org>
On Fri, 7 Jul 2006 17:10:15 -0700 Andrew Morton wrote:
> "Randy.Dunlap" <rdunlap@xenotime.net> wrote:
> >
> > + if (!pcie_dev_registered)
> > + pcie_port_bus_register();
> > +
>
> Wonderful. You're forced to drop all error checking on the floor because
> pcie_port_bus_register() assumes that nobody could possibly ever be
> interested in actually checking for errors.
>
> What happens if the bus_register() fails and the driver cheerily blunders
> along assuming that pcie_port_bus_type is registered? Incomprehensible lkml
> oops reports, I'm suspecting..
>
> Let's start stamping this out. Could I please ask that you first prepare a
> patch which fixes pcie_port_bus_register() (and mark it __must_check) and
> then let's actually, like, check for errors?
From: Randy Dunlap <rdunlap@xenotime.net>
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>
---
drivers/pci/pcie/portdrv.h | 2 +-
drivers/pci/pcie/portdrv_core.c | 5 +++--
drivers/pci/pcie/portdrv_pci.c | 9 +++++++--
3 files changed, 11 insertions(+), 5 deletions(-)
--- linux-2618-rc1.orig/drivers/pci/pcie/portdrv_core.c
+++ linux-2618-rc1/drivers/pci/pcie/portdrv_core.c
@@ -6,6 +6,7 @@
* Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com)
*/
+#include <linux/compiler.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/kernel.h>
@@ -402,9 +403,9 @@ void pcie_port_device_remove(struct pci_
pci_disable_msi(dev);
}
-void pcie_port_bus_register(void)
+int __must_check pcie_port_bus_register(void)
{
- bus_register(&pcie_port_bus_type);
+ return bus_register(&pcie_port_bus_type);
}
void pcie_port_bus_unregister(void)
--- linux-2618-rc1.orig/drivers/pci/pcie/portdrv_pci.c
+++ linux-2618-rc1/drivers/pci/pcie/portdrv_pci.c
@@ -127,12 +127,17 @@ static struct pci_driver pcie_portdrv =
static int __init pcie_portdrv_init(void)
{
- int retval = 0;
+ int retval;
- pcie_port_bus_register();
+ retval = pcie_port_bus_register();
+ if (retval) {
+ printk(KERN_WARNING "PCIE: bus_register error: %d\n", retval);
+ goto out;
+ }
retval = pci_register_driver(&pcie_portdrv);
if (retval)
pcie_port_bus_unregister();
+ out:
return retval;
}
--- linux-2618-rc1.orig/drivers/pci/pcie/portdrv.h
+++ linux-2618-rc1/drivers/pci/pcie/portdrv.h
@@ -39,7 +39,7 @@ extern int pcie_port_device_suspend(stru
extern int pcie_port_device_resume(struct pci_dev *dev);
#endif
extern void pcie_port_device_remove(struct pci_dev *dev);
-extern void pcie_port_bus_register(void);
+extern int pcie_port_bus_register(void);
extern void pcie_port_bus_unregister(void);
#endif /* _PORTDRV_H_ */
---
prev parent reply other threads:[~2006-07-09 5:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-07 23:52 [PATCH] PCIE: create sysfs directory on first use Randy.Dunlap
2006-07-08 0:07 ` Valdis.Kletnieks
2006-07-08 0:10 ` Andrew Morton
2006-07-08 0:17 ` Randy.Dunlap
2006-07-09 5:58 ` Randy.Dunlap [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060708225825.0c1fac16.rdunlap@xenotime.net \
--to=rdunlap@xenotime.net \
--cc=akpm@osdl.org \
--cc=davej@codemonkey.org.uk \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®