Skip to contentSkip to conversation

efi_loader: Fix warning in efi_load_image()

PATCH Applied Tom Rini 3 participants 3 messages Sep 30, 2018 – Oct 16, 2018

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 efi_loader: Fix warning in efi_load_image()

As observed with clang:
lib/efi_loader/efi_boottime.c:1624:7: warning: variable 'info'

      is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
                if (ret != EFI_SUCCESS)
                    ^~~~~~~~~~~~~~~~~~
lib/efi_loader/efi_boottime.c:1653:7: note: uninitialized use
      occurs here
        free(info);
             ^~~~
lib/efi_loader/efi_boottime.c:1624:3: note: remove the 'if' if
      its condition is always false
                if (ret != EFI_SUCCESS)
                ^~~~~~~~~~~~~~~~~~~~~~~
lib/efi_loader/efi_boottime.c:1602:31: note: initialize the
      variable 'info' to silence this warning
        struct efi_loaded_image *info;
                                     ^
                                      = NULL

Rather than change how we unwind the function it makes the most sense to initialize info to NULL so that we can continue to pass it to free().

Fixes c982874e930d ("efi_loader: refactor efi_setup_loaded_image()")
Cc Heinrich Schuchardt <[email protected]>
Cc Alexander Graf <[email protected]>
---
 lib/efi_loader/efi_boottime.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/efi_loader/efi_boottime.c +1 -1
index 97eb19cd14d2..ddf857ff267d 100644
@@ -1599,7 +1599,7 @@ static efi_status_t EFIAPI efi_load_image(bool boot_policy,
 					  efi_uintn_t source_size,
 					  efi_handle_t *image_handle)
 {
-	struct efi_loaded_image *info;
+	struct efi_loaded_image *info = NULL;
 	struct efi_loaded_image_obj **image_obj =
 		(struct efi_loaded_image_obj **)image_handle;
 	efi_status_t ret;
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 efi_loader: Fix warning in efi_load_image()

Quoted 19 lines · Tom Rini

As observed with clang:
lib/efi_loader/efi_boottime.c:1624:7: warning: variable 'info'

      is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
                if (ret != EFI_SUCCESS)
                    ^~~~~~~~~~~~~~~~~~
lib/efi_loader/efi_boottime.c:1653:7: note: uninitialized use
      occurs here
        free(info);
             ^~~~
lib/efi_loader/efi_boottime.c:1624:3: note: remove the 'if' if
      its condition is always false
                if (ret != EFI_SUCCESS)
                ^~~~~~~~~~~~~~~~~~~~~~~
lib/efi_loader/efi_boottime.c:1602:31: note: initialize the
      variable 'info' to silence this warning
        struct efi_loaded_image *info;
                                     ^
                                      = NULL
Quoted 7 lines

Rather than change how we unwind the function it makes the most sense to initialize info to NULL so that we can continue to pass it to free().

Fixes c982874e930d ("efi_loader: refactor efi_setup_loaded_image()")
Cc Heinrich Schuchardt <[email protected]>
Cc Alexander Graf <[email protected]>
#2 lore raw
In reply to Tom Rini
Quoted 19 lines

As observed with clang:
lib/efi_loader/efi_boottime.c:1624:7: warning: variable 'info'

      is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
                if (ret != EFI_SUCCESS)
                    ^~~~~~~~~~~~~~~~~~
lib/efi_loader/efi_boottime.c:1653:7: note: uninitialized use
      occurs here
        free(info);
             ^~~~
lib/efi_loader/efi_boottime.c:1624:3: note: remove the 'if' if
      its condition is always false
                if (ret != EFI_SUCCESS)
                ^~~~~~~~~~~~~~~~~~~~~~~
lib/efi_loader/efi_boottime.c:1602:31: note: initialize the
      variable 'info' to silence this warning
        struct efi_loaded_image *info;
                                     ^
                                      = NULL
Quoted 8 lines

Rather than change how we unwind the function it makes the most sense to initialize info to NULL so that we can continue to pass it to free().

Fixes c982874e930d ("efi_loader: refactor efi_setup_loaded_image()")
Cc Heinrich Schuchardt <[email protected]>
Cc Alexander Graf <[email protected]>

Thanks, applied to efi-2018.11

Alex