[Skiboot] [PATCH 3/3] [Device] Verify zalloc returned valid pointer
Ananth N Mavinakayanahalli
ananth at in.ibm.com
Wed Jun 17 18:23:52 AEST 2015
Else, we are dereferencing NULL
Signed-off-by: Ananth N Mavinakayanahalli <ananth at in.ibm.com>
---
core/device.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/core/device.c b/core/device.c
index 09f76d7..ba427de 100644
--- a/core/device.c
+++ b/core/device.c
@@ -348,6 +348,9 @@ struct dt_property *dt_add_property_nstr(struct dt_node *node,
struct dt_property *p;
char *tmp = zalloc(vlen + 1);
+ if (!tmp)
+ return NULL;
+
strncpy(tmp, value, vlen);
p = dt_add_property(node, name, tmp, strlen(tmp)+1);
free(tmp);
More information about the Skiboot
mailing list