From abab733fc24158f0195967e5b6fc69a0de4658a3 Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Tue, 23 Sep 2025 12:27:21 +0200 Subject: [PATCH] mkimage: fit: do not ignore fdt_setprop return code All explicit calls to fdt_setprop* in tools/ are checked except those three. Let's add a check for the return code of fdt_setprop_u32() calls. Signed-off-by: Quentin Schulz --- tools/fit_image.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tools/fit_image.c b/tools/fit_image.c index 7e2a12aa7d0..d026f6ff9c8 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -658,13 +658,25 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname) } if (params->external_offset > 0) { /* An external offset positions the data absolutely. */ - fdt_setprop_u32(fdt, node, FIT_DATA_POSITION_PROP, - params->external_offset + buf_ptr); + ret = fdt_setprop_u32(fdt, node, FIT_DATA_POSITION_PROP, + params->external_offset + buf_ptr); } else { - fdt_setprop_u32(fdt, node, FIT_DATA_OFFSET_PROP, - buf_ptr); + ret = fdt_setprop_u32(fdt, node, FIT_DATA_OFFSET_PROP, + buf_ptr); } - fdt_setprop_u32(fdt, node, FIT_DATA_SIZE_PROP, len); + + if (ret) { + ret = -EINVAL; + goto err_munmap; + } + + ret = fdt_setprop_u32(fdt, node, FIT_DATA_SIZE_PROP, len); + + if (ret) { + ret = -EINVAL; + goto err_munmap; + } + buf_ptr += ALIGN(len, align_size); } -- 2.47.3