efi/libstub: Unify initrd loading across architectures
Hello Arvind Sankar,
The patch f61900fd0ebf: "efi/libstub: Unify initrd loading across architectures" from Apr 30, 2020, leads to the following static checker warning:
drivers/firmware/efi/libstub/efi-stub-helper.c:481 efi_load_initrd_cmdline()
error: we previously assumed 'image' could be null (see line 474)
drivers/firmware/efi/libstub/efi-stub-helper.c
466 static
467 efi_status_t efi_load_initrd_cmdline(efi_loaded_image_t *image,
468 unsigned long *load_addr,
469 unsigned long *load_size,
470 unsigned long soft_limit,
471 unsigned long hard_limit)
472 {
473 if (!IS_ENABLED(CONFIG_EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER) ||
474 (IS_ENABLED(CONFIG_X86) && (!efi_is_native() || image == NULL))) {
^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^Assume X86 is not configured but "image" is NULL.
475 *load_addr = *load_size = 0;
476 return EFI_SUCCESS;
477 }
478
479 return handle_cmdline_files(image, L"initrd=", sizeof(L"initrd=") - 2,
^^^^^
Dereferenced inside the function.
480 soft_limit, hard_limit,
481 load_addr, load_size);
482 }
regards,
dan carpenter
Ard Biesheuvel
maintainerQuoted 23 lines · Dan Carpenter
Hello Arvind Sankar,
The patch
f61900fd0ebf: "efi/libstub: Unify initrd loading across architectures" from Apr 30, 2020, leads to the following static checker warning:
drivers/firmware/efi/libstub/efi-stub-helper.c:481efi_load_initrd_cmdline()
error: we previously assumed 'image' could be null (see line 474)
drivers/firmware/efi/libstub/efi-stub-helper.c
466 static
467efi_status_tefi_load_initrd_cmdline(efi_loaded_image_t *image,468 unsigned long *load_addr, 469 unsigned long *load_size, 470 unsigned long soft_limit, 471 unsigned long hard_limit) 472 { 473 if (!IS_ENABLED(CONFIG_EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER) || 474 (IS_ENABLED(CONFIG_X86) && (!efi_is_native() || image == NULL))) { ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^Assume X86 is not configured but "image" is NULL.
Quoted 7 lines
475 *load_addr = *load_size = 0; 476 return EFI_SUCCESS; 477 } 478 479 return handle_cmdline_files(image, L"initrd=", sizeof(L"initrd=") - 2, ^^^^^Dereferenced inside the function.
image is guaranteed to be non-null on !x86 architectures.
Quoted 7 lines
480 soft_limit, hard_limit, 481 load_addr, load_size); 482 }regards,
dan carpenter