From 28031a079167923cf261b1d672a20ed652ad0657 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Thu, 28 Mar 2019 15:26:37 -0600 Subject: [PATCH] efidisk: NULL pointer dereference in grub_efidisk_get_device_name() Function grub_efi_find_last_device_path() may return NULL when called from grub_efidisk_get_device_name(). Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- grub-core/disk/efi/efidisk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index 78ab2d21a..9e20af70e 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -836,6 +836,9 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle) { grub_efi_device_path_t *dup_ldp; dup_ldp = grub_efi_find_last_device_path (dup_dp); + if (! dup_ldp) + break; + if (!(GRUB_EFI_DEVICE_PATH_TYPE (dup_ldp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE && (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE || GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE)))