[PATCH] environment: fix free() of unitialized variable

Sascha Hauer s.hauer at pengutronix.de
Wed Feb 5 01:48:32 PST 2025


of_find_path() doesn't initialize the outpath on error. In order to
free() it in the error path we have to initialize devpath.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/of/barebox.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/of/barebox.c b/drivers/of/barebox.c
index 9b8da679e2..e6bcff7116 100644
--- a/drivers/of/barebox.c
+++ b/drivers/of/barebox.c
@@ -34,7 +34,7 @@ static char *environment_probe_1node_binding(struct device *dev)
 static char *environment_probe_2node_binding(struct device *dev)
 {
 	const char *filepath;
-	char *devpath;
+	char *devpath = NULL;
 	int ret;
 
 	ret = of_find_path(dev->of_node, "device-path", &devpath,
-- 
2.39.5




More information about the barebox mailing list