[PATCH] tools: Fix error handling in fit_config_get_hash_list

Francois Berder fberder at outlook.fr
Mon Jan 19 15:47:20 CET 2026


If an error occurs in fit_config_get_hash_list function,
one needs to free the node_inc string list.

Signed-off-by: Francois Berder <fberder at outlook.fr>
---
 tools/image-host.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/image-host.c b/tools/image-host.c
index 48d69191c92..635a75afe5c 100644
--- a/tools/image-host.c
+++ b/tools/image-host.c
@@ -924,19 +924,23 @@ static int fit_config_get_hash_list(const void *fit, int conf_noffset,
 				if (allow_missing)
 					continue;
 
+				strlist_free(node_inc);
 				return -ENOENT;
 			}
 
 			ret = fit_config_add_hash(fit, image_noffset, node_inc,
 						  conf_name, sig_name, iname);
-			if (ret < 0)
+			if (ret < 0) {
+				strlist_free(node_inc);
 				return ret;
+			}
 
 			image_count++;
 		}
 	}
 
 	if (!image_count) {
+		strlist_free(node_inc);
 		fprintf(stderr, "Failed to find any images for configuration '%s/%s'\n",
 			conf_name, sig_name);
 		return -ENOMSG;
@@ -945,6 +949,7 @@ static int fit_config_get_hash_list(const void *fit, int conf_noffset,
 	return 0;
 
 err_mem:
+	strlist_free(node_inc);
 	fprintf(stderr, "Out of memory processing configuration '%s/%s'\n", conf_name,
 		sig_name);
 	return -ENOMEM;
-- 
2.43.0



More information about the U-Boot mailing list