[SPARC]: Check kzalloc() return value in SUN4D irq/iommu init.
[powerpc.git] / arch / sparc / kernel / prom.c
index 4b06dcb..2cc302b 100644 (file)
@@ -243,7 +243,7 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len
                        void *old_val = prop->value;
                        int ret;
 
-                       ret = prom_setprop(dp->node, name, val, len);
+                       ret = prom_setprop(dp->node, (char *) name, val, len);
                        err = -EINVAL;
                        if (ret >= 0) {
                                prop->value = new_val;
@@ -444,6 +444,7 @@ static struct property * __init build_one_prop(phandle node, char *prev, char *s
        static struct property *tmp = NULL;
        struct property *p;
        int len;
+       const char *name;
 
        if (tmp) {
                p = tmp;
@@ -456,25 +457,30 @@ static struct property * __init build_one_prop(phandle node, char *prev, char *s
 
        p->name = (char *) (p + 1);
        if (special_name) {
+               strcpy(p->name, special_name);
                p->length = special_len;
                p->value = prom_early_alloc(special_len);
                memcpy(p->value, special_val, special_len);
        } else {
                if (prev == NULL) {
-                       prom_firstprop(node, p->name);
+                       name = prom_firstprop(node, NULL);
                } else {
-                       prom_nextprop(node, prev, p->name);
+                       name = prom_nextprop(node, prev, NULL);
                }
-               if (strlen(p->name) == 0) {
+               if (strlen(name) == 0) {
                        tmp = p;
                        return NULL;
                }
+               strcpy(p->name, name);
                p->length = prom_getproplen(node, p->name);
                if (p->length <= 0) {
                        p->length = 0;
                } else {
                        p->value = prom_early_alloc(p->length + 1);
-                       prom_getproperty(node, p->name, p->value, p->length);
+                       len = prom_getproperty(node, p->name, p->value,
+                                              p->length);
+                       if (len <= 0)
+                               p->length = 0;
                        ((unsigned char *)p->value)[p->length] = '\0';
                }
        }