[Skiboot] [PATCH] libflash: Initialise entries list earlier
Oliver O'Halloran
oohall at gmail.com
Fri May 26 14:07:48 AEST 2017
In the bail-out path we call ffs_close() to tear down the partially
initialised ffs_handle. ffs_close() expects the entries list to be
initialised so we need to do that earlier to prevent a null pointer
dereference.
Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
libflash/libffs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libflash/libffs.c b/libflash/libffs.c
index dca40188edb8..763e061c7a19 100644
--- a/libflash/libffs.c
+++ b/libflash/libffs.c
@@ -256,6 +256,7 @@ int ffs_init(uint32_t offset, uint32_t max_size, struct blocklevel_device *bl,
f->toc_offset = offset;
f->max_size = max_size;
f->bl = bl;
+ list_head_init(&f->hdr.entries);
/* Convert and check flash header */
rc = ffs_check_convert_header(&f->hdr, &raw_hdr);
@@ -298,7 +299,6 @@ int ffs_init(uint32_t offset, uint32_t max_size, struct blocklevel_device *bl,
goto out;
}
- list_head_init(&f->hdr.entries);
for (i = 0; i < be32_to_cpu(raw_hdr.entry_count); i++) {
struct ffs_entry *ent = calloc(1, sizeof(struct ffs_entry));
if (!ent) {
--
2.9.3
More information about the Skiboot
mailing list