From 5a55df727c33141c12ef17f3cbefef397c603661 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Mon, 17 Aug 2015 22:16:17 +1000 Subject: libflash: check ffs_part_info return value in ffs_init 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 Signed-off-by: Stewart Smith --- 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) { -- cgit v1.1