bbc6a89
From e8ab5a1a9e2889eb59d1fa494ba441a53698dcd2 Mon Sep 17 00:00:00 2001
dd84573
From: Rob Clark <rclark@redhat.com>
bbc6a89
Date: Wed, 19 Jul 2017 15:47:41 -0400
31cddd6
Subject: [PATCH] Fix a segfault in lsefi
dd84573
dd84573
when protocols_per_handle returns error, we can't use the pointers we
dd84573
passed to it, and that includes trusting num_protocols.
dd84573
dd84573
Signed-off-by: Peter Jones <pjones@redhat.com>
bbc6a89
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
dd84573
---
bbc6a89
 grub-core/commands/efi/lsefi.c | 4 +++-
bbc6a89
 1 file changed, 3 insertions(+), 1 deletion(-)
dd84573
dd84573
diff --git a/grub-core/commands/efi/lsefi.c b/grub-core/commands/efi/lsefi.c
ec4acbb
index d901c389263..d1ce99af438 100644
dd84573
--- a/grub-core/commands/efi/lsefi.c
dd84573
+++ b/grub-core/commands/efi/lsefi.c
bbc6a89
@@ -109,8 +109,10 @@ grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)),
bbc6a89
 
dd84573
       status = efi_call_3 (grub_efi_system_table->boot_services->protocols_per_handle,
dd84573
 			   handle, &protocols, &num_protocols);
bbc6a89
-      if (status != GRUB_EFI_SUCCESS)
bbc6a89
+      if (status != GRUB_EFI_SUCCESS) {
bbc6a89
 	grub_printf ("Unable to retrieve protocols\n");
bbc6a89
+	continue;
bbc6a89
+      }
dd84573
       for (j = 0; j < num_protocols; j++)
dd84573
 	{
dd84573
 	  for (k = 0; k < ARRAY_SIZE (known_protocols); k++)