summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorZheng Bao <fishbaozi@gmail.com>2021-05-27 11:26:12 +0800
committerPatrick Georgi <pgeorgi@google.com>2021-06-14 05:52:40 +0000
commitb035f589401b0060771be432851c339843fffeca (patch)
tree483e61bd88cf9f5471b20195b3d2b19a08bbd33e /util
parent3201ec343afca40387e495df3945fcc08a16067a (diff)
downloadcoreboot-b035f589401b0060771be432851c339843fffeca.tar.gz
coreboot-b035f589401b0060771be432851c339843fffeca.tar.bz2
coreboot-b035f589401b0060771be432851c339843fffeca.zip
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>
Diffstat (limited to 'util')
-rw-r--r--util/amdfwtool/amdfwtool.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c
index 825dea6b6410..1e75278b5e69 100644
--- a/util/amdfwtool/amdfwtool.c
+++ b/util/amdfwtool/amdfwtool.c
@@ -397,10 +397,13 @@ static void fill_dir_header(void *directory, uint32_t count, uint32_t cookie, co
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: