util/amdfwtool: Fix NULL pointer dereference in fill_dir_header
Move the NULL pointer check to the beginning of the fill_dir_header function before any dereference of the directory pointer. This prevents the potential segmentation fault that could occur if directory is NULL. This fixes CID 1540835 - Dereference before null check (REVERSE_NULL). Change-Id: I12bb146d59839381478034f974b7d408f92ae677 Signed-off-by: Martin Roth <gaumless@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/88617 Reviewed-by: Patrick Rudolph <patrick.rudolph@9elements.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
280d3a25e8
commit
9411c6e7c7
1 changed files with 5 additions and 5 deletions
|
|
@ -586,6 +586,11 @@ static void copy_psp_header(void *bak, void *orig)
|
|||
|
||||
static void fill_dir_header(void *directory, uint32_t count, context *ctx)
|
||||
{
|
||||
if (ctx == NULL || directory == NULL) {
|
||||
fprintf(stderr, "Calling %s with NULL pointers\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
psp_combo_directory *cdir = directory;
|
||||
psp_directory_table *dir = directory;
|
||||
bios_directory_table *bdir = directory;
|
||||
|
|
@ -593,11 +598,6 @@ static void fill_dir_header(void *directory, uint32_t count, context *ctx)
|
|||
uint32_t cookie = ((psp_directory_table *)directory)->header.cookie;
|
||||
uint32_t table_size = 0;
|
||||
|
||||
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. */
|
||||
adjust_current_pointer(ctx, 0, TABLE_ALIGNMENT);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue