[PATCH 5/8] uimage: fix memory leak in error path

Sascha Hauer s.hauer at pengutronix.de
Wed Jan 24 23:45:17 PST 2018


handle->name is dynamically allocated, so free it in the error path.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
Reported-by: Stefan Lengfeld <contact at stefanchrist.eu>
---
 common/uimage.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/uimage.c b/common/uimage.c
index b6f0f109ca..e857c11d37 100644
--- a/common/uimage.c
+++ b/common/uimage.c
@@ -202,6 +202,8 @@ again:
 	return handle;
 err_out:
 	close(fd);
+
+	free(handle->name);
 	free(handle);
 	if (IS_BUILTIN(CONFIG_FS_TFTP) && !stat(uimage_tmp, &s))
 		unlink(uimage_tmp);
-- 
2.15.1




More information about the barebox mailing list