aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/chrp
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2007-11-23 00:43:04 -0500
committerPaul Mackerras <paulus@samba.org>2007-12-20 01:13:34 -0500
commit9ac71d00398674aaec664f30559f0a21d963862f (patch)
treeb683032ac55b92e2760a3e0dafb7ce9658378e79 /arch/powerpc/platforms/chrp
parent08a644ecef9383b109b763f5087265fd1759875f (diff)
[POWERPC] CHRP: Fix possible NULL pointer dereference
This fixes a possible NULL pointer dereference inside of strncmp() if of_get_property() fails. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/platforms/chrp')
-rw-r--r--arch/powerpc/platforms/chrp/setup.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/arch/powerpc/platforms/chrp/setup.c b/arch/powerpc/platforms/chrp/setup.c
index 59306261f5b2..42a21bab76c8 100644
--- a/arch/powerpc/platforms/chrp/setup.c
+++ b/arch/powerpc/platforms/chrp/setup.c
@@ -115,7 +115,7 @@ void chrp_show_cpuinfo(struct seq_file *m)
115 seq_printf(m, "machine\t\t: CHRP %s\n", model); 115 seq_printf(m, "machine\t\t: CHRP %s\n", model);
116 116
117 /* longtrail (goldengate) stuff */ 117 /* longtrail (goldengate) stuff */
118 if (!strncmp(model, "IBM,LongTrail", 13)) { 118 if (model && !strncmp(model, "IBM,LongTrail", 13)) {
119 /* VLSI VAS96011/12 `Golden Gate 2' */ 119 /* VLSI VAS96011/12 `Golden Gate 2' */
120 /* Memory banks */ 120 /* Memory banks */
121 sdramen = (in_le32(gg2_pci_config_base + GG2_PCI_DRAM_CTRL) 121 sdramen = (in_le32(gg2_pci_config_base + GG2_PCI_DRAM_CTRL)
@@ -203,15 +203,20 @@ static void __init sio_fixup_irq(const char *name, u8 device, u8 level,
203static void __init sio_init(void) 203static void __init sio_init(void)
204{ 204{
205 struct device_node *root; 205 struct device_node *root;
206 const char *model;
206 207
207 if ((root = of_find_node_by_path("/")) && 208 root = of_find_node_by_path("/");
208 !strncmp(of_get_property(root, "model", NULL), 209 if (!root)
209 "IBM,LongTrail", 13)) { 210 return;
211
212 model = of_get_property(root, "model", NULL);
213 if (model && !strncmp(model, "IBM,LongTrail", 13)) {
210 /* logical device 0 (KBC/Keyboard) */ 214 /* logical device 0 (KBC/Keyboard) */
211 sio_fixup_irq("keyboard", 0, 1, 2); 215 sio_fixup_irq("keyboard", 0, 1, 2);
212 /* select logical device 1 (KBC/Mouse) */ 216 /* select logical device 1 (KBC/Mouse) */
213 sio_fixup_irq("mouse", 1, 12, 2); 217 sio_fixup_irq("mouse", 1, 12, 2);
214 } 218 }
219
215 of_node_put(root); 220 of_node_put(root);
216} 221}
217 222