Message ID | 20200407165258.916007-1-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
Series | opal: mtd_info: memset a mtd_info struct to keep static analyzers happy | expand |
On 2020-04-07 10:52 a.m., Colin King wrote: > From: Colin Ian King <colin.king@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@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", > Acked-by: Alex Hung <alex.hung@canonical.com>
On 4/8/20 12:52 AM, Colin King wrote: > From: Colin Ian King <colin.king@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@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", > Acked-by: Ivan Hu <ivan.hu@canonical.com>
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",