[Skiboot] [PATCH 1/2] Fix resource leak on crash

Stewart Smith stewart at linux.vnet.ibm.com
Wed Nov 11 16:38:06 AEDT 2015


Even though we're heading to abort(), it seems like some static
analysis checkers still think we're leaking. So.... well, let's
just make them happy and free the memory. It's harmless to do
that.

Signed-off-by: Stewart Smith <stewart at linux.vnet.ibm.com>
---
 core/device.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/core/device.c b/core/device.c
index 483baec7cd4c..89e530f26554 100644
--- a/core/device.c
+++ b/core/device.c
@@ -318,14 +318,18 @@ static struct dt_property *new_property(struct dt_node *node,
 					const char *name, size_t size)
 {
 	struct dt_property *p = malloc(sizeof(*p) + size);
+	char *path;
+
 	if (!p) {
 		prerror("Failed to allocate property \"%s\" for %s of %zu bytes\n",
 			name, dt_get_path(node), size);
 		abort();
 	}
 	if (dt_find_property(node, name)) {
+		path = dt_get_path(node);
 		prerror("Duplicate property \"%s\" in node %s\n",
-			name, dt_get_path(node));
+			name, path);
+		free(path);
 		abort();
 
 	}
-- 
2.1.4



More information about the Skiboot mailing list