util/grub-install: Fix NULL pointer dereferences

Two grub_device_open() calls does not have associated NULL checks
for returned values. Fix that and appease the Coverity.

Fixes: CID 314583

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Daniel Kiper committed 2021-03-02 15:54:17 +01:00
1 parent 7c8a2b5d14
commit 8b3a95655b
1 file changed
+4
+4
View File
@@ -1784,6 +1784,8 @@ main (int argc, char *argv[])
fill_core_services (core_services); fill_core_services (core_services);
ins_dev = grub_device_open (install_drive); ins_dev = grub_device_open (install_drive);
if (ins_dev == NULL)
grub_util_error ("%s", grub_errmsg);
bless (ins_dev, core_services, 0); bless (ins_dev, core_services, 0);
@@ -1884,6 +1886,8 @@ main (int argc, char *argv[])
fill_core_services(core_services); fill_core_services(core_services);
ins_dev = grub_device_open (install_drive); ins_dev = grub_device_open (install_drive);
if (ins_dev == NULL)
grub_util_error ("%s", grub_errmsg);
bless (ins_dev, boot_efi, 1); bless (ins_dev, boot_efi, 1);
if (!removable && update_nvram) if (!removable && update_nvram)