]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[POWERPC] CHRP: Fix possible NULL pointer dereference
authorCyrill Gorcunov <gorcunov@gmail.com>
Fri, 23 Nov 2007 05:43:04 +0000 (16:43 +1100)
committerPaul Mackerras <paulus@samba.org>
Thu, 20 Dec 2007 06:13:34 +0000 (17:13 +1100)
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>
arch/powerpc/platforms/chrp/setup.c

index 59306261f5b2991a329be96680c771ef134a9852..42a21bab76c860e51f97fdee3b6b32317f37e803 100644 (file)
@@ -115,7 +115,7 @@ void chrp_show_cpuinfo(struct seq_file *m)
        seq_printf(m, "machine\t\t: CHRP %s\n", model);
 
        /* longtrail (goldengate) stuff */
-       if (!strncmp(model, "IBM,LongTrail", 13)) {
+       if (model && !strncmp(model, "IBM,LongTrail", 13)) {
                /* VLSI VAS96011/12 `Golden Gate 2' */
                /* Memory banks */
                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,
 static void __init sio_init(void)
 {
        struct device_node *root;
+       const char *model;
 
-       if ((root = of_find_node_by_path("/")) &&
-           !strncmp(of_get_property(root, "model", NULL),
-                       "IBM,LongTrail", 13)) {
+       root = of_find_node_by_path("/");
+       if (!root)
+               return;
+
+       model = of_get_property(root, "model", NULL);
+       if (model && !strncmp(model, "IBM,LongTrail", 13)) {
                /* logical device 0 (KBC/Keyboard) */
                sio_fixup_irq("keyboard", 0, 1, 2);
                /* select logical device 1 (KBC/Mouse) */
                sio_fixup_irq("mouse", 1, 12, 2);
        }
+
        of_node_put(root);
 }