efi_loader: Fix warning in efi_load_image()
authorTom Rini <trini@konsulko.com>
Sun, 30 Sep 2018 14:38:15 +0000 (10:38 -0400)
committerAlexander Graf <agraf@suse.de>
Tue, 16 Oct 2018 14:41:18 +0000 (16:41 +0200)
commit1c3b2f4ae1da02f173315b1fc02b05122c02bd44
tree59e17c11d31040f6e5041e9e94d8c190785a82c1
parentb417d475b28164e12a6351390f234ed49ec14c0e
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()")
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
lib/efi_loader/efi_boottime.c