EFI_EXIT2() stores its argument in _r and passes that to EFI_EXIT(),
whose own _r shadows it, so typeof(_r) _r = _r reads the uninitialized
inner variable and the traced status is garbage.

This only affects trace output was and was detected by a warning when
being compiled with clang.

Fixes: c05e8108d769 ("efi: loader: add support for tracing calls back into 
UEFI")
Signed-off-by: Ahmad Fatoum <[email protected]>
---
 include/efi/loader/trace.h | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/include/efi/loader/trace.h b/include/efi/loader/trace.h
index 4acf7c1634cc..767812f84e26 100644
--- a/include/efi/loader/trace.h
+++ b/include/efi/loader/trace.h
@@ -34,24 +34,25 @@ const char *__efi_nesting_dec(void);
  */
 #ifndef EFI_EXIT
 #define EFI_EXIT(ret) ({ \
-       typeof(ret) _r = ret; \
+       typeof(ret) __efi_r = ret; \
        __EFI_PRINT("%sEFI: Exit: %s: %s (%u)\n", __efi_nesting_dec(), \
-               __func__, efi_strerror((uintptr_t)_r), (u32)((uintptr_t) _r & 
~EFI_ERROR_MASK)); \
-       _r; \
+               __func__, efi_strerror((uintptr_t)__efi_r), \
+               (u32)((uintptr_t) __efi_r & ~EFI_ERROR_MASK)); \
+       __efi_r; \
        })
 #endif
 
 #ifndef EFI_EXIT2
 #define EFI_EXIT2(ret, val) ({ \
-       typeof(ret) _r = ret; \
-       if (EFI_ERROR(_r)) \
-               EFI_EXIT(_r); \
+       typeof(ret) __efi_r2 = ret; \
+       if (EFI_ERROR(__efi_r2)) \
+               EFI_EXIT(__efi_r2); \
        else \
                __EFI_PRINT("%sEFI: Exit: %s: %s (%u) = 0x%llx\n", 
__efi_nesting_dec(), \
-                       __func__, efi_strerror((uintptr_t)_r), \
-                       (u32)((uintptr_t) _r & ~EFI_ERROR_MASK), \
+                       __func__, efi_strerror((uintptr_t)__efi_r2), \
+                       (u32)((uintptr_t) __efi_r2 & ~EFI_ERROR_MASK), \
                        (u64)(uintptr_t)(val)); \
-       _r; \
+       __efi_r2; \
        })
 #endif
 
-- 
2.47.3


Reply via email to