public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] - adds missing checks in drivers/pci/probe.c.
@ 2004-09-20 15:33 Luiz Fernando N. Capitulino
  2004-09-24 16:00 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Luiz Fernando N. Capitulino @ 2004-09-20 15:33 UTC (permalink / raw)
  To: greg; +Cc: linux-kernel


 Hi Greg,

 I noticed drivers/pci/probe.c::pci_scan_bus_parented() has some functions which
the return value is not checked.

 The patch bellow adds the check for device_register(), class_device_register(),
class_device_create_file() and sysfs_create_link().

(hope the error label names are not too ugly).


Signed-off-by: Luiz Capitulino <lcapitulino@conectiva.com.br>

 drivers/pci/probe.c |   36 ++++++++++++++++++++++++++++--------
 1 files changed, 28 insertions(+), 8 deletions(-)


diff -X /home/lcapitulino/kernels/2.6/dontdiff -Nparu a/drivers/pci/probe.c a~/drivers/pci/probe.c
--- a/drivers/pci/probe.c	2004-09-17 19:18:21.000000000 -0300
+++ a~/drivers/pci/probe.c	2004-09-19 22:06:30.000000000 -0300
@@ -750,6 +750,7 @@ unsigned int __devinit pci_do_scan_bus(s
 
 struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent, int bus, struct pci_ops *ops, void *sysdata)
 {
+	int error;
 	struct pci_bus *b;
 	struct device *dev;
 
@@ -769,9 +770,7 @@ struct pci_bus * __devinit pci_scan_bus_
 	if (pci_find_bus(pci_domain_nr(b), bus)) {
 		/* If we already got to this bus through a different bridge, ignore it */
 		DBG("PCI: Bus %02x already known\n", bus);
-		kfree(dev);
-		kfree(b);
-		return NULL;
+		goto err_out;
 	}
 	list_add_tail(&b->node, &pci_root_buses);
 
@@ -779,15 +778,23 @@ struct pci_bus * __devinit pci_scan_bus_
 	dev->parent = parent;
 	dev->release = pci_release_bus_bridge_dev;
 	sprintf(dev->bus_id, "pci%04x:%02x", pci_domain_nr(b), bus);
-	device_register(dev);
+	error = device_register(dev);
+	if (error)
+		goto dev_reg_err;
 	b->bridge = get_device(dev);
 
 	b->class_dev.class = &pcibus_class;
 	sprintf(b->class_dev.class_id, "%04x:%02x", pci_domain_nr(b), bus);
-	class_device_register(&b->class_dev);
-	class_device_create_file(&b->class_dev, &class_device_attr_cpuaffinity);
-
-	sysfs_create_link(&b->class_dev.kobj, &b->bridge->kobj, "bridge");
+	error = class_device_register(&b->class_dev);
+	if (error)
+		goto class_dev_reg_err;
+	error = class_device_create_file(&b->class_dev, &class_device_attr_cpuaffinity);
+	if (error)
+		goto class_dev_create_file_err;
+
+	error = sysfs_create_link(&b->class_dev.kobj, &b->bridge->kobj, "bridge");
+	if (error)
+		goto sys_create_link_err;
 
 	b->number = b->secondary = bus;
 	b->resource[0] = &ioport_resource;
@@ -798,6 +805,19 @@ struct pci_bus * __devinit pci_scan_bus_
 	pci_bus_add_devices(b);
 
 	return b;
+
+sys_create_link_err:
+	class_device_remove_file(&b->class_dev, &class_device_attr_cpuaffinity);
+class_dev_create_file_err:
+	class_device_unregister(&b->class_dev);
+class_dev_reg_err:
+	device_unregister(dev);
+dev_reg_err:
+	list_del(&b->node);
+err_out:
+	kfree(dev);
+	kfree(b);
+	return NULL;
 }
 EXPORT_SYMBOL(pci_scan_bus_parented);
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] - adds missing checks in drivers/pci/probe.c.
  2004-09-20 15:33 [PATCH] - adds missing checks in drivers/pci/probe.c Luiz Fernando N. Capitulino
@ 2004-09-24 16:00 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2004-09-24 16:00 UTC (permalink / raw)
  To: Luiz Fernando N. Capitulino; +Cc: linux-kernel

On Mon, Sep 20, 2004 at 12:33:26PM -0300, Luiz Fernando N. Capitulino wrote:
> 
>  Hi Greg,
> 
>  I noticed drivers/pci/probe.c::pci_scan_bus_parented() has some functions which
> the return value is not checked.
> 
>  The patch bellow adds the check for device_register(), class_device_register(),
> class_device_create_file() and sysfs_create_link().
> 
> (hope the error label names are not too ugly).
> 
> 
> Signed-off-by: Luiz Capitulino <lcapitulino@conectiva.com.br>

Applied, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-09-24 16:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-20 15:33 [PATCH] - adds missing checks in drivers/pci/probe.c Luiz Fernando N. Capitulino
2004-09-24 16:00 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox