diff mbox

Fix resource leak on crash (similar to 125f95e)

Message ID 1447285697-19722-1-git-send-email-stewart@linux.vnet.ibm.com
State Accepted
Headers show

Commit Message

Stewart Smith Nov. 11, 2015, 11:48 p.m. UTC
The error paths here are a bit suspicious anyway as we're allocating
memory in a failure path for having failed to allocate memory.
One can hope that the memory allocated to display the error is less
than the memory we attempted to allocate in the first place.

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
---
 core/device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/core/device.c b/core/device.c
index 89e530f26554..c5f863454983 100644
--- a/core/device.c
+++ b/core/device.c
@@ -321,8 +321,10 @@  static struct dt_property *new_property(struct dt_node *node,
 	char *path;
 
 	if (!p) {
+		path = dt_get_path(node);
 		prerror("Failed to allocate property \"%s\" for %s of %zu bytes\n",
-			name, dt_get_path(node), size);
+			name, path, size);
+		free(path);
 		abort();
 	}
 	if (dt_find_property(node, name)) {