[PATCH] DTC: Fix memory leak on flatname.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



If flatname was not referenced by the "node" structure, the reference to the
allocated string is lost at function exit.

We need to free it if is not used by "node".

Signed-off-by: Jean-Christophe Dubois <jcd@xxxxxxxxxxxxxxx>
---
 flattree.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/flattree.c b/flattree.c
index ec14954..089b976 100644
--- a/flattree.c
+++ b/flattree.c
@@ -797,6 +797,10 @@ static struct node *unflatten_tree(struct inbuf *dtbuf,
 		}
 	} while (val != FDT_END_NODE);
 
+	if (node->name != flatname) {
+		free(flatname);
+	}
+
 	return node;
 }
 
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux