* [PATCH] unix/platform: Initialize variable to fix grub-install on UEFI system
@ 2018-10-23 13:00 Paul Menzel
2018-10-31 12:31 ` Daniel Kiper
0 siblings, 1 reply; 2+ messages in thread
From: Paul Menzel @ 2018-10-23 13:00 UTC (permalink / raw)
To: grub-devel; +Cc: pkg-grub-devel
[-- Attachment #1: Type: text/plain, Size: 1962 bytes --]
Date: Tue, 23 Oct 2018 14:37:57 +0200
On a UEFI system, were no boot entry *grub* is present, currently,
`grub-install` fails with an error.
$ efibootmgr
BootCurrent: 0000
Timeout: 0 seconds
BootOrder: 0001,0006,0003,0004,0005
Boot0001 Diskette Drive
Boot0003* USB Storage Device
Boot0004* CD/DVD/CD-RW Drive
Boot0005 Onboard NIC
Boot0006* WDC WD2500AAKX-75U6AA0
$ sudo grub-install /dev/sda
Installing for x86_64-efi platform.
grub-install: error: efibootmgr failed to register the boot entry: Unknown error 22020.
The error code is always different, and the error message (incorrectly)
points to efibootmgr.
But, the error is in GRUB’s function
`grub_install_remove_efi_entries_by_distributor()`, where the variable
`rc` for the return value, is uninitialized and never set, when no boot
entry for the distributor is found.
The content of that uninitialized variable is then returned as the error
code of efibootmgr.
Set the variable to 0, so that success is returned, when no entry needs
to be deleted.
Tested on Dell OptiPlex 7010 with firmware A28.
$ sudo ./grub-install /dev/sda
Installing for x86_64-efi platform.
Installation finished. No error reported.
[1]: https://github.com/rhboot/efibootmgr/issues/100
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
---
grub-core/osdep/unix/platform.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/grub-core/osdep/unix/platform.c b/grub-core/osdep/unix/platform.c
index ca448bc11..55b8f4016 100644
--- a/grub-core/osdep/unix/platform.c
+++ b/grub-core/osdep/unix/platform.c
@@ -85,7 +85,7 @@ grub_install_remove_efi_entries_by_distributor (const char *efi_distributor)
pid_t pid = grub_util_exec_pipe ((const char * []){ "efibootmgr", NULL }, &fd);
char *line = NULL;
size_t len = 0;
- int rc;
+ int rc = 0;
if (!pid)
{
--
2.17.1
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5174 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] unix/platform: Initialize variable to fix grub-install on UEFI system
2018-10-23 13:00 [PATCH] unix/platform: Initialize variable to fix grub-install on UEFI system Paul Menzel
@ 2018-10-31 12:31 ` Daniel Kiper
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Kiper @ 2018-10-31 12:31 UTC (permalink / raw)
To: Paul Menzel; +Cc: grub-devel, pkg-grub-devel
On Tue, Oct 23, 2018 at 03:00:13PM +0200, Paul Menzel wrote:
> Date: Tue, 23 Oct 2018 14:37:57 +0200
>
> On a UEFI system, were no boot entry *grub* is present, currently,
> `grub-install` fails with an error.
>
> $ efibootmgr
> BootCurrent: 0000
> Timeout: 0 seconds
> BootOrder: 0001,0006,0003,0004,0005
> Boot0001 Diskette Drive
> Boot0003* USB Storage Device
> Boot0004* CD/DVD/CD-RW Drive
> Boot0005 Onboard NIC
> Boot0006* WDC WD2500AAKX-75U6AA0
> $ sudo grub-install /dev/sda
> Installing for x86_64-efi platform.
> grub-install: error: efibootmgr failed to register the boot entry: Unknown error 22020.
>
> The error code is always different, and the error message (incorrectly)
> points to efibootmgr.
>
> But, the error is in GRUB???s function
> `grub_install_remove_efi_entries_by_distributor()`, where the variable
> `rc` for the return value, is uninitialized and never set, when no boot
> entry for the distributor is found.
>
> The content of that uninitialized variable is then returned as the error
> code of efibootmgr.
>
> Set the variable to 0, so that success is returned, when no entry needs
> to be deleted.
>
> Tested on Dell OptiPlex 7010 with firmware A28.
>
> $ sudo ./grub-install /dev/sda
> Installing for x86_64-efi platform.
> Installation finished. No error reported.
>
> [1]: https://github.com/rhboot/efibootmgr/issues/100
>
> Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Daniel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-10-31 12:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-23 13:00 [PATCH] unix/platform: Initialize variable to fix grub-install on UEFI system Paul Menzel
2018-10-31 12:31 ` Daniel Kiper
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.