[PATCH] opal: mtd_info: memset a mtd_info struct to keep static analyzers happy

Colin King colin.king at canonical.com
Tue Apr 7 16:52:57 UTC 2020


From: Colin Ian King <colin.king at canonical.com>

Coverity throws a warning of a potential use of unitialized fields
in the mtd_info struct, so memset it to zero before calling the ioctl.

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/opal/mtd_info.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/opal/mtd_info.c b/src/opal/mtd_info.c
index b9473edf..0af500d2 100644
--- a/src/opal/mtd_info.c
+++ b/src/opal/mtd_info.c
@@ -126,6 +126,7 @@ static int mtd_dev_query(fwts_framework *fw, char *mtd_devnode)
 		return FWTS_ERROR;
 	}
 
+	(void)memset(&mtd_info, 0, sizeof(mtd_info));
 	if (ioctl(fd, MEMGETINFO, &mtd_info)) {
 		(void)close(fd);
 		fwts_failed(fw, LOG_LEVEL_CRITICAL, "OPAL MTD Info",
-- 
2.25.1




More information about the fwts-devel mailing list