[Skiboot] [PATCH] libflash: check ffs_part_info return value in ffs_init
Cyril Bur
cyrilbur at gmail.com
Tue Jul 28 15:33:02 AEST 2015
On Tue, 28 Jul 2015 11:07:59 +0800
Jeremy Kerr <jk at ozlabs.org> wrote:
> Current build 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.
>
Thanks Jeremy,
Was this `make check`? I'm surprised I didn't hit those.
> Signed-off-by: Jeremy Kerr <jk at ozlabs.org>
Reviewed-by: Cyril Bur <cyril.bur at au1.ibm.com>
>
> ---
> 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