[Skiboot] [PATCH 2/2] libflash/libffs: Check for NULL and set return pointer in ffs_next_side()
Sam Mendoza-Jonas
sam at mendozajonas.com
Tue Jan 12 16:29:09 AEDT 2016
On Tue, Jan 12, 2016 at 04:15:39PM +1100, Cyril Bur wrote:
> Currently there are two error cases that ffs_next_side() may hit and will
> leave the return pointer untouched. This isn't a huge problem as the caller
> should be checking the return value anyway but as we know, callers don't
> always do that.
>
> It doesn't hurt for ffs_next_side() to make it as clear as possible that it
> encountered a problem.
>
> Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
Reviewed-by: Sam Mendoza-Jonas <sam at mendozajonas.com>
> ---
> libflash/libffs.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/libflash/libffs.c b/libflash/libffs.c
> index cc534e2..51d9856 100644
> --- a/libflash/libffs.c
> +++ b/libflash/libffs.c
> @@ -294,6 +294,12 @@ int ffs_next_side(struct ffs_handle *ffs, struct ffs_handle **new_ffs,
> {
> int rc;
> uint32_t index, offset, max_size;
> +
> + if (!ffs || !new_ffs)
> + return FLASH_ERR_PARM_ERROR;
> +
> + *new_ffs = NULL;
> +
> rc = ffs_lookup_part(ffs, "OTHER_SIDE", &index);
> if (rc)
> return rc;
> --
> 2.7.0
>
> _______________________________________________
> Skiboot mailing list
> Skiboot at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/skiboot
More information about the Skiboot
mailing list