Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/54999 )
Change subject: amdfwtool: Null check the pointers before using them ......................................................................
amdfwtool: Null check the pointers before using them
BUG=b:188769922
Reported-by: Coverity (CID:1438963) Change-Id: Ia520e33c9e4065236478665fb0ef047fa47c9b81 Signed-off-by: Zheng Bao fishbaozi@gmail.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/54999 Reviewed-by: Felix Held felix-coreboot@felixheld.de Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M util/amdfwtool/amdfwtool.c 1 file changed, 5 insertions(+), 2 deletions(-)
Approvals: build bot (Jenkins): Verified Felix Held: Looks good to me, approved
diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c index 825dea6..1e75278 100644 --- a/util/amdfwtool/amdfwtool.c +++ b/util/amdfwtool/amdfwtool.c @@ -397,10 +397,13 @@
if (!count) return; + if (ctx == NULL || directory == NULL) { + fprintf(stderr, "Calling %s with NULL pointers\n", __func__); + return; + }
/* The table size needs to be 0x1000 aligned. So align the end of table. */ - if (ctx != NULL) - ctx->current = ALIGN(ctx->current, TABLE_ALIGNMENT); + ctx->current = ALIGN(ctx->current, TABLE_ALIGNMENT);
switch (cookie) { case PSP2_COOKIE: