]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
[SPARC]: Fix EBUS use of uninitialized variable.
authorDavid S. Miller <davem@sunset.davemloft.net>
Thu, 27 Sep 2007 20:09:28 +0000 (13:09 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Thu, 27 Sep 2007 20:09:28 +0000 (13:09 -0700)
If of_get_property() fails, it returns NULL and the 'len'
parameter is undefined.  So we need to explicitly set len
to zero in such cases.

Noticed by Al Viro.

Signed-off-by: David S. Miller <davem@davemloft.net>
arch/sparc/kernel/ebus.c
arch/sparc64/kernel/ebus.c

index e2d02fd13f35f6284d7f54fe4352d60b9279dd12..d850785b20808716b5d843af7877712db1b9dc7d 100644 (file)
@@ -156,6 +156,8 @@ void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_device *d
        dev->prom_node = dp;
 
        regs = of_get_property(dp, "reg", &len);
+       if (!regs)
+               len = 0;
        if (len % sizeof(struct linux_prom_registers)) {
                prom_printf("UGH: proplen for %s was %d, need multiple of %d\n",
                            dev->prom_node->name, len,
index bc9ae36f7a43cd1de77cf6469762f21fc4ce6bd3..04ab81cb4f483f24e78c6d74c40e044d29383203 100644 (file)
@@ -375,7 +375,10 @@ static void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_de
                dev->num_addrs = 0;
                dev->num_irqs = 0;
        } else {
-               (void) of_get_property(dp, "reg", &len);
+               const int *regs = of_get_property(dp, "reg", &len);
+
+               if (!regs)
+                       len = 0;
                dev->num_addrs = len / sizeof(struct linux_prom_registers);
 
                for (i = 0; i < dev->num_addrs; i++)