1From 8b3a95655b4391122e7b0315d8cc6f876caf8183 Mon Sep 17 00:00:00 2001 2From: Daniel Kiper <daniel.kiper@oracle.com> 3Date: Thu, 25 Feb 2021 18:35:01 +0100 4Subject: [PATCH] util/grub-install: Fix NULL pointer dereferences 5 6Two grub_device_open() calls does not have associated NULL checks 7for returned values. Fix that and appease the Coverity. 8 9Fixes: CID 314583 10 11Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com> 12Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> 13Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com> 14--- 15 util/grub-install.c | 4 ++++ 16 1 file changed, 4 insertions(+) 17 18diff --git a/util/grub-install.c b/util/grub-install.c 19index a82725f..367350f 100644 20--- a/util/grub-install.c 21+++ b/util/grub-install.c 22@@ -1775,6 +1775,8 @@ main (int argc, char *argv[]) 23 fill_core_services (core_services); 24 25 ins_dev = grub_device_open (install_drive); 26+ if (ins_dev == NULL) 27+ grub_util_error ("%s", grub_errmsg); 28 29 bless (ins_dev, core_services, 0); 30 31@@ -1875,6 +1877,8 @@ main (int argc, char *argv[]) 32 fill_core_services(core_services); 33 34 ins_dev = grub_device_open (install_drive); 35+ if (ins_dev == NULL) 36+ grub_util_error ("%s", grub_errmsg); 37 38 bless (ins_dev, boot_efi, 1); 39 if (!removable && update_nvram) 40-- 412.14.2 42 43