[Skiboot] [PATCH 1/2] libflash: check ffs_part_info return value in ffs_init

Jeremy Kerr jk at ozlabs.org
Mon Aug 17 16:55:08 AEST 2015


Current packaging builds (which specify -O2) fail for me, with:

     CC  libffs.o
 ../../libflash/libffs.c: In function ‘ffs_init’:
 ../../libflash/libffs.c:149:8: error: ‘start’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
      rc = blocklevel_ecc_protect(bl, start, total_size);
         ^
 ../../libflash/libffs.c:149:8: error: ‘total_size’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 ../../libflash/libffs.c:148:7: error: ‘ecc’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     if (ecc) {
        ^
 cc1: all warnings being treated as errors

This is because we're not checking for the return value of
ffs_part_info, which may return with start/total_size/ecc uninitialised.

Signed-off-by: Jeremy Kerr <jk at ozlabs.org>

---
 libflash/libffs.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libflash/libffs.c b/libflash/libffs.c
index 0164071..3010a61 100644
--- a/libflash/libffs.c
+++ b/libflash/libffs.c
@@ -144,7 +144,13 @@ int ffs_init(uint32_t offset, uint32_t max_size, struct blocklevel_device *bl,
 		uint32_t start, total_size;
 		bool ecc;
 		for (i = 0; i < f->hdr.entry_count; i++) {
-			ffs_part_info(f, i, NULL, &start, &total_size, NULL, &ecc);
+			rc = ffs_part_info(f, i, NULL, &start, &total_size,
+					NULL, &ecc);
+			if (rc) {
+				FL_ERR("FFS: Failed to read ffs partition %d\n",
+						i);
+				goto out;
+			}
 			if (ecc) {
 				rc = blocklevel_ecc_protect(bl, start, total_size);
 				if (rc) {


More information about the Skiboot mailing list