linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PPC: CELLEB - fix potential NULL pointer dereference
@ 2007-11-26  7:46 Cyrill Gorcunov
  2007-11-28  8:52 ` Ishizaki Kou
  2007-11-28  9:48 ` Michael Ellerman
  0 siblings, 2 replies; 8+ messages in thread
From: Cyrill Gorcunov @ 2007-11-26  7:46 UTC (permalink / raw)
  To: PPCML; +Cc: Olof Johansson, Paul Mackerras, LKML

[-- Attachment #1: Type: text/plain, Size: 218 bytes --]

This patch adds checking for NULL value returned to prevent possible
NULL pointer dereference.
Also two unneeded 'return' are removed.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
Any comments are welcome.

[-- Attachment #2: ppc-celleb-fix-null.diff --]
[-- Type: text/plain, Size: 2105 bytes --]

 arch/powerpc/platforms/celleb/pci.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/celleb/pci.c b/arch/powerpc/platforms/celleb/pci.c
index 6bc32fd..9b8bb01 100644
--- a/arch/powerpc/platforms/celleb/pci.c
+++ b/arch/powerpc/platforms/celleb/pci.c
@@ -138,8 +138,6 @@ static void celleb_config_read_fake(unsigned char *config, int where,
 		*val = celleb_fake_config_readl(p);
 		break;
 	}
-
-	return;
 }
 
 static void celleb_config_write_fake(unsigned char *config, int where,
@@ -158,7 +156,6 @@ static void celleb_config_write_fake(unsigned char *config, int where,
 		celleb_fake_config_writel(val, p);
 		break;
 	}
-	return;
 }
 
 static int celleb_fake_pci_read_config(struct pci_bus *bus,
@@ -348,9 +345,25 @@ static int __init celleb_setup_fake_pci_device(struct device_node *node,
 	pr_debug("PCI: res assigned 0x%016lx\n", (unsigned long)*res);
 
 	wi0 = of_get_property(node, "device-id", NULL);
+	if (unlikely((!wi0))) {
+		printk(KERN_ERR "PCI: device-id not found.\n");
+		goto error;
+	}
 	wi1 = of_get_property(node, "vendor-id", NULL);
+	if (unlikely((!wi1))) {
+		printk(KERN_ERR "PCI: vendor-id not found.\n");
+		goto error;
+	}
 	wi2 = of_get_property(node, "class-code", NULL);
+	if (unlikely((!wi2))) {
+		printk(KERN_ERR "PCI: class-code not found.\n");
+		goto error;
+	}
 	wi3 = of_get_property(node, "revision-id", NULL);
+	if (unlikely((!wi3))) {
+		printk(KERN_ERR "PCI: revision-id not found.\n");
+		goto error;
+	}
 
 	celleb_config_write_fake(*config, PCI_DEVICE_ID, 2, wi0[0] & 0xffff);
 	celleb_config_write_fake(*config, PCI_VENDOR_ID, 2, wi1[0] & 0xffff);
@@ -372,6 +385,10 @@ static int __init celleb_setup_fake_pci_device(struct device_node *node,
 	celleb_setup_pci_base_addrs(hose, devno, fn, num_base_addr);
 
 	li = of_get_property(node, "interrupts", &rlen);
+	if (!li) {
+		printk(KERN_ERR "PCI: interrupts not found.\n");
+		goto error;
+	}
 	val = li[0];
 	celleb_config_write_fake(*config, PCI_INTERRUPT_PIN, 1, 1);
 	celleb_config_write_fake(*config, PCI_INTERRUPT_LINE, 1, val);

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

end of thread, other threads:[~2007-11-29  7:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-26  7:46 [PATCH] PPC: CELLEB - fix potential NULL pointer dereference Cyrill Gorcunov
2007-11-28  8:52 ` Ishizaki Kou
2007-11-28  9:48 ` Michael Ellerman
2007-11-28 10:53   ` Cyrill Gorcunov
2007-11-28 10:59     ` Cyrill Gorcunov
2007-11-29  3:22       ` Ishizaki Kou
2007-11-29  5:41         ` Cyrill Gorcunov
2007-11-29  7:44           ` [PATCH] PPC: CELLEB - fix possible " Ishizaki Kou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).