]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
mkimage: fit: do not ignore fdt_setprop return code
authorQuentin Schulz <quentin.schulz@cherry.de>
Tue, 23 Sep 2025 10:27:21 +0000 (12:27 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 10 Oct 2025 19:28:36 +0000 (13:28 -0600)
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 <quentin.schulz@cherry.de>
tools/fit_image.c

index 7e2a12aa7d0f128fa9b0287a3d29b2fcd3cf4c27..d026f6ff9c855ba41f11ab8b9b8bd82247b68927 100644 (file)
@@ -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);
        }