[Skiboot] [PATCH 2/2] libflash/libffs: Check for NULL and set return pointer in ffs_next_side()

Cyril Bur cyril.bur at au1.ibm.com
Tue Jan 12 16:15:39 AEDT 2016

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>
 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)
+	*new_ffs = NULL;
 	rc = ffs_lookup_part(ffs, "OTHER_SIDE", &index);
 	if (rc)
 		return rc;

More information about the Skiboot mailing list