[PATCH] common: bootm: Add missing check of fit_open_image() return code

Albert Schwarzkopf a.schwarzkopf at phytec.de
Wed Sep 9 06:54:46 EDT 2020


Check the return code of fit_open_image() inside bootm_load_initrd(). 
Without this check, the code works with undefined values of 
"initrd_size" and "initrd" should fit_open_image() fail.

Signed-off-by: Albert Schwarzkopf <a.schwarzkopf at phytec.de>
---
 common/bootm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/common/bootm.c b/common/bootm.c
index 7f22ca5ce..5713edad3 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -232,7 +232,11 @@ int bootm_load_initrd(struct image_data *data, unsigned long load_address)
 
 		ret = fit_open_image(data->os_fit, data->fit_config, "ramdisk",
 				     &initrd, &initrd_size);
-
+		if (ret) {
+			pr_err("Cannot open ramdisk image in FIT image: %s\n",
+					strerror(-ret));
+			return ret;
+		}
 		data->initrd_res = request_sdram_region("initrd",
 				load_address,
 				initrd_size);
-- 
2.25.1




More information about the barebox mailing list