From 3b616010e06847104de4d7cfdf9314f6aff1d9e4 Mon Sep 17 00:00:00 2001 From: Jack Ren Date: Mon, 28 May 2018 13:40:59 +0800 Subject: [PATCH] hv: handle the case of empty hypervisor cmdline Fix a bug: When the hypervisor cmdline is empty, the hypervisor will be unable to boot up. Signed-off-by: Jack Ren Reviewed-by: Kevin Tian --- hypervisor/bsp/uefi/efi/boot.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/hypervisor/bsp/uefi/efi/boot.c b/hypervisor/bsp/uefi/efi/boot.c index 7158ea0dd..ba5e26cc8 100644 --- a/hypervisor/bsp/uefi/efi/boot.c +++ b/hypervisor/bsp/uefi/efi/boot.c @@ -368,17 +368,15 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *_table) */ cmdline16 = StrDuplicate(options); bootloader_name = strstr_16(cmdline16, bootloader_param); - if (bootloader_name) + if (bootloader_name) { bootloader_name = bootloader_name + StrLen(bootloader_param); - - n = bootloader_name; - i = 0; - while (*n && !isspace((CHAR8)*n) && (*n < 0xff)) { - n++; i++; - } - *n++ = '\0'; - - if (!bootloader_name) { + n = bootloader_name; + i = 0; + while (*n && !isspace((CHAR8)*n) && (*n < 0xff)) { + n++; i++; + } + *n++ = '\0'; + } else { /* * If we reach this point, it means we did not receive a specific * bootloader name to be used. Fall back to the default bootloader