Thejaswani Putta has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/33625
Change subject: Fix NULL dereference issues found by Klocwork ......................................................................
Fix NULL dereference issues found by Klocwork
Signed-off-by: Thejaswani Putta thejaswani.putta@intel.com Change-Id: Ia63ab85af610f5d83b5bd6596916a1d4d459adbf
Change-Id: I9ed0fc9b03d9136c582377035cf478d3abf83c41 --- M payloads/libpayload/curses/form/fty_alnum.c M payloads/libpayload/curses/form/fty_alpha.c M payloads/libpayload/curses/form/fty_enum.c M payloads/libpayload/curses/form/fty_int.c M src/soc/intel/cannonlake/romstage/fsp_params.c 5 files changed, 15 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/25/33625/1
diff --git a/payloads/libpayload/curses/form/fty_alnum.c b/payloads/libpayload/curses/form/fty_alnum.c index cda23dc..7c4f1bc 100644 --- a/payloads/libpayload/curses/form/fty_alnum.c +++ b/payloads/libpayload/curses/form/fty_alnum.c @@ -163,6 +163,8 @@ unsigned char *bp = (unsigned char *)field_buffer(field, 0); bool result = (width < 0);
+ if(bp == NULL) + return result; Check_CTYPE_Field(result, bp, width, Check_This_Character); return (result); } diff --git a/payloads/libpayload/curses/form/fty_alpha.c b/payloads/libpayload/curses/form/fty_alpha.c index 917a9e0..336658a 100644 --- a/payloads/libpayload/curses/form/fty_alpha.c +++ b/payloads/libpayload/curses/form/fty_alpha.c @@ -163,6 +163,8 @@ unsigned char *bp = (unsigned char *)field_buffer(field, 0); bool result = (width < 0);
+ if(bp == NULL) + return result; Check_CTYPE_Field(result, bp, width, Check_This_Character); return (result); } diff --git a/payloads/libpayload/curses/form/fty_enum.c b/payloads/libpayload/curses/form/fty_enum.c index 2fd96f0..4d1edb1 100644 --- a/payloads/libpayload/curses/form/fty_enum.c +++ b/payloads/libpayload/curses/form/fty_enum.c @@ -293,6 +293,8 @@ char *s, *t, *p; int res;
+ if(bp == NULL) + return FALSE; while (kwds && (s = (*kwds++))) { if ((res = Compare((unsigned char *)s, bp, ccase)) != NOMATCH) @@ -348,6 +350,9 @@ int cnt = args->count; unsigned char *bp = (unsigned char *)field_buffer(field, 0);
+ if (bp == NULL) + return FALSE; + if (kwds) { while (cnt--) @@ -386,6 +391,8 @@ bool ccase = args->checkcase; unsigned char *bp = (unsigned char *)field_buffer(field, 0);
+ if(bp == NULL) + return FALSE; if (kwds) { while (cnt--) diff --git a/payloads/libpayload/curses/form/fty_int.c b/payloads/libpayload/curses/form/fty_int.c index 0eddedf..e9ea995 100644 --- a/payloads/libpayload/curses/form/fty_int.c +++ b/payloads/libpayload/curses/form/fty_int.c @@ -172,6 +172,8 @@ char buf[100]; bool result = FALSE;
+ if( bp == NULL) + return result; while (*bp && *bp == ' ') bp++; if (*bp) diff --git a/src/soc/intel/cannonlake/romstage/fsp_params.c b/src/soc/intel/cannonlake/romstage/fsp_params.c index 77bad8f..c47d193 100644 --- a/src/soc/intel/cannonlake/romstage/fsp_params.c +++ b/src/soc/intel/cannonlake/romstage/fsp_params.c @@ -102,7 +102,8 @@ { const struct device *dev = dev_find_slot(0, PCH_DEVFN_LPC); const struct device *smbus = dev_find_slot(0, PCH_DEVFN_SMBUS); - assert(dev != NULL); + if (dev == NULL) + return; const config_t *config = dev->chip_info; FSP_M_CONFIG *m_cfg = &mupd->FspmConfig; FSP_M_TEST_CONFIG *tconfig = &mupd->FspmTestConfig;