[Skiboot] [PATCH v2 13/23] libffs: Fix ffs_lookup_part() return value

Michael Neuling mikey at neuling.org
Sun Jun 25 05:17:18 AEST 2017


From: Benjamin Herrenschmidt <benh at kernel.crashing.org>

It would return success when the part wasn't found

Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
Signed-off-by: Michael Neuling <mikey at neuling.org>
---
 libflash/libffs.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libflash/libffs.c b/libflash/libffs.c
index 7ae9050e77..8943505f7b 100644
--- a/libflash/libffs.c
+++ b/libflash/libffs.c
@@ -348,18 +348,20 @@ void ffs_close(struct ffs_handle *ffs)
 int ffs_lookup_part(struct ffs_handle *ffs, const char *name,
 		    uint32_t *part_idx)
 {
-	int i = 0;
 	struct ffs_entry *ent = NULL;
+	int i = 0, rc = FFS_ERR_PART_NOT_FOUND;
 
 	list_for_each(&ffs->hdr.entries, ent, list) {
-		if (strncmp(name, ent->name, sizeof(ent->name)) == 0)
+		if (strncmp(name, ent->name, sizeof(ent->name)) == 0) {
+			rc = 0;
 			break;
+		}
 		i++;
 	}
 
-	if (part_idx)
+	if (rc == 0 && part_idx)
 		*part_idx = i;
-	return ent ? 0 : FFS_ERR_PART_NOT_FOUND;
+	return rc;
 }
 
 int ffs_part_info(struct ffs_handle *ffs, uint32_t part_idx,
-- 
2.11.0



More information about the Skiboot mailing list