[Skiboot] [PATCH] libflash/libffs: Fix possible NULL dereference

Cyril Bur cyril.bur at au1.ibm.com
Fri Nov 11 11:33:34 AEDT 2016


Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
---
 libflash/libffs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libflash/libffs.c b/libflash/libffs.c
index 549e6d5..96b7c55 100644
--- a/libflash/libffs.c
+++ b/libflash/libffs.c
@@ -307,6 +307,8 @@ int ffs_part_info(struct ffs_handle *ffs, uint32_t part_idx,
 
 	if (name) {
 		n = malloc(PART_NAME_MAX + 1);
+		if (!n)
+			return FLASH_ERR_MALLOC_FAILED;
 		memset(n, 0, PART_NAME_MAX + 1);
 		strncpy(n, ent.name, PART_NAME_MAX);
 		*name = n;
-- 
2.10.2



More information about the Skiboot mailing list