]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
efi/libstub: Avoid returning uninitialized data from setup_graphics()
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Sun, 26 Apr 2020 19:49:46 +0000 (21:49 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 7 Jun 2020 11:16:45 +0000 (13:16 +0200)
[ Upstream commit 081d5150845ba3fa49151a2f55d3cc03b0987509 ]

Currently, setup_graphics() ignores the return value of efi_setup_gop(). As
AllocatePool() does not zero out memory, the screen information table will
contain uninitialized data in this case.

We should free the screen information table if efi_setup_gop() returns an
error code.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Link: https://lore.kernel.org/r/20200426194946.112768-1-xypron.glpk@gmx.de
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/firmware/efi/libstub/arm-stub.c

index 7bbef4a6735048977b616a9f018d8d04fdcf5951..30e77a9e62b2f2cd192e7f9c632d8032868b6dcf 100644 (file)
@@ -59,7 +59,11 @@ static struct screen_info *setup_graphics(void)
                si = alloc_screen_info();
                if (!si)
                        return NULL;
-               efi_setup_gop(si, &gop_proto, size);
+               status = efi_setup_gop(si, &gop_proto, size);
+               if (status != EFI_SUCCESS) {
+                       free_screen_info(si);
+                       return NULL;
+               }
        }
        return si;
 }