Skip to contentSkip to conversation

fit: check return value of fit_image_get_data_size()

PATCH New Heinrich Schuchardt 3 participants 3 messages Mar 11, 2020 – Mar 13, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fit: check return value of fit_image_get_data_size()

GCC-10 reports:

In file included from tools/common/image-fit.c:1:
include/image.h: In function ?fit_image_get_data_and_size?:
./tools/../common/image-fit.c:1015:9: warning: ?len? may be used uninitialized in this function [-Wmaybe-uninitialized]

 1015 |   *size = len;
      |   ~~~~~~^~~~~
./tools/../common/image-fit.c:996:6: note: ?len? was declared here
  996 |  int len;
      |      ^~~

Add the missing check of the return value of fit_image_get_data_size().

Fixes c3c863880479 ("add FIT data-position & data-offset property support")
---
 common/image-fit.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
common/image-fit.c +4 -2
index f3bb00c98a..4435bc4f1d 100644
@@ -1011,8 +1011,10 @@ int fit_image_get_data_and_size(const void *fit, int noffset,
 	if (external_data) {
 		debug("External Data\n");
 		ret = fit_image_get_data_size(fit, noffset, &len);
-		*data = fit + offset;
-		*size = len;
+		if (!ret) {
+			*data = fit + offset;
+			*size = len;
+		}
 	} else {
 		ret = fit_image_get_data(fit, noffset, data, size);
 	}

--
2.25.1

#1 lore raw

PATCH 1/1 fit: check return value of fit_image_get_data_size()

Quoted 13 lines · Heinrich Schuchardt

GCC-10 reports:

In file included from tools/common/image-fit.c:1:
include/image.h: In function ?fit_image_get_data_and_size?:
./tools/../common/image-fit.c:1015:9: warning: ?len? may be used uninitialized in this function [-Wmaybe-uninitialized]

 1015 |   *size = len;
      |   ~~~~~~^~~~~
./tools/../common/image-fit.c:996:6: note: ?len? was declared here
  996 |  int len;
      |      ^~~
Quoted 4 lines

Add the missing check of the return value of fit_image_get_data_size().

Fixes c3c863880479 ("add FIT data-position & data-offset property support")
Quoted 24 lines
---
 common/image-fit.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
common/image-fit.c +4 -3
index f3bb00c98a..4435bc4f1d 100644
@@ -1011,8 +1011,10 @@ int fit_image_get_data_and_size(const void *fit, int noffset,
        if (external_data) {
                debug("External Data\n");
                ret = fit_image_get_data_size(fit, noffset, &len);
-               *data = fit + offset;
-               *size = len;
+               if (!ret) {
+                       *data = fit + offset;
+                       *size = len;
+               }
        } else {
                ret = fit_image_get_data(fit, noffset, data, size);
        }
--

2.25.1

#2 lore raw

PATCH 1/1 fit: check return value of fit_image_get_data_size()

In reply to Heinrich Schuchardt
Quoted 12 lines · Heinrich Schuchardt

GCC-10 reports:

In file included from tools/common/image-fit.c:1:
include/image.h: In function ?fit_image_get_data_and_size?:
./tools/../common/image-fit.c:1015:9: warning: ?len? may be used uninitialized in this function [-Wmaybe-uninitialized]

 1015 |   *size = len;
      |   ~~~~~~^~~~~
./tools/../common/image-fit.c:996:6: note: ?len? was declared here
  996 |  int len;
      |      ^~~
Quoted 5 lines

Add the missing check of the return value of fit_image_get_data_size().

Fixes c3c863880479 ("add FIT data-position & data-offset property support")

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200313/03e6a166/attachment.sig>