diff options
author | Cyrill Gorcunov <gorcunov@gmail.com> | 2007-11-29 02:44:18 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-12-05 22:44:30 -0500 |
commit | 3a1c81f4faa8f93a36533fa8900a2f488528aab9 (patch) | |
tree | 79675459dffb9a1724998a900f96c6e57ccb6191 /arch/powerpc | |
parent | eb8f2763412893147c00e065773f46be5634f263 (diff) |
[POWERPC] CELLEB: Fix possible NULL pointer dereference
This adds checking for NULL returned value from of_get_property to
prevent possible NULL pointer dereference in the case when expected
properties are not present.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/platforms/celleb/pci.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/arch/powerpc/platforms/celleb/pci.c b/arch/powerpc/platforms/celleb/pci.c index 6bc32fda7a6b..13ec4a606b96 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, | |||
138 | *val = celleb_fake_config_readl(p); | 138 | *val = celleb_fake_config_readl(p); |
139 | break; | 139 | break; |
140 | } | 140 | } |
141 | |||
142 | return; | ||
143 | } | 141 | } |
144 | 142 | ||
145 | static void celleb_config_write_fake(unsigned char *config, int where, | 143 | 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, | |||
158 | celleb_fake_config_writel(val, p); | 156 | celleb_fake_config_writel(val, p); |
159 | break; | 157 | break; |
160 | } | 158 | } |
161 | return; | ||
162 | } | 159 | } |
163 | 160 | ||
164 | static int celleb_fake_pci_read_config(struct pci_bus *bus, | 161 | static int celleb_fake_pci_read_config(struct pci_bus *bus, |
@@ -351,6 +348,10 @@ static int __init celleb_setup_fake_pci_device(struct device_node *node, | |||
351 | wi1 = of_get_property(node, "vendor-id", NULL); | 348 | wi1 = of_get_property(node, "vendor-id", NULL); |
352 | wi2 = of_get_property(node, "class-code", NULL); | 349 | wi2 = of_get_property(node, "class-code", NULL); |
353 | wi3 = of_get_property(node, "revision-id", NULL); | 350 | wi3 = of_get_property(node, "revision-id", NULL); |
351 | if (!wi0 || !wi1 || !wi2 || !wi3) { | ||
352 | printk(KERN_ERR "PCI: Missing device tree properties.\n"); | ||
353 | goto error; | ||
354 | } | ||
354 | 355 | ||
355 | celleb_config_write_fake(*config, PCI_DEVICE_ID, 2, wi0[0] & 0xffff); | 356 | celleb_config_write_fake(*config, PCI_DEVICE_ID, 2, wi0[0] & 0xffff); |
356 | celleb_config_write_fake(*config, PCI_VENDOR_ID, 2, wi1[0] & 0xffff); | 357 | celleb_config_write_fake(*config, PCI_VENDOR_ID, 2, wi1[0] & 0xffff); |
@@ -372,6 +373,10 @@ static int __init celleb_setup_fake_pci_device(struct device_node *node, | |||
372 | celleb_setup_pci_base_addrs(hose, devno, fn, num_base_addr); | 373 | celleb_setup_pci_base_addrs(hose, devno, fn, num_base_addr); |
373 | 374 | ||
374 | li = of_get_property(node, "interrupts", &rlen); | 375 | li = of_get_property(node, "interrupts", &rlen); |
376 | if (!li) { | ||
377 | printk(KERN_ERR "PCI: interrupts not found.\n"); | ||
378 | goto error; | ||
379 | } | ||
375 | val = li[0]; | 380 | val = li[0]; |
376 | celleb_config_write_fake(*config, PCI_INTERRUPT_PIN, 1, 1); | 381 | celleb_config_write_fake(*config, PCI_INTERRUPT_PIN, 1, 1); |
377 | celleb_config_write_fake(*config, PCI_INTERRUPT_LINE, 1, val); | 382 | celleb_config_write_fake(*config, PCI_INTERRUPT_LINE, 1, val); |