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>
This commit is contained in:
Zheng Bao 2021-05-27 11:26:12 +08:00 committed by Patrick Georgi
parent 3201ec343a
commit b035f58940
1 changed files with 5 additions and 2 deletions

View File

@ -397,9 +397,12 @@ 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);
switch (cookie) {