efi/libstub: Handle NULL cmdline
authorArvind Sankar <nivedita@alum.mit.edu>
Wed, 29 Jul 2020 19:33:00 +0000 (15:33 -0400)
committerArd Biesheuvel <ardb@kernel.org>
Thu, 20 Aug 2020 09:18:55 +0000 (11:18 +0200)
Treat a NULL cmdline the same as empty. Although this is unlikely to
happen in practice, the x86 kernel entry does check for NULL cmdline and
handles it, so do it here as well.

Cc: <stable@vger.kernel.org>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Link: https://lore.kernel.org/r/20200729193300.598448-1-nivedita@alum.mit.edu
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/libstub/efi-stub-helper.c

index 37ff34e7b85e4441e4aeb2e6109899ed82aa7e4f..f53652a3a1060906aeefc6936f4f70fdc1adf88e 100644 (file)
@@ -187,10 +187,14 @@ int efi_printk(const char *fmt, ...)
  */
 efi_status_t efi_parse_options(char const *cmdline)
 {
-       size_t len = strlen(cmdline) + 1;
+       size_t len;
        efi_status_t status;
        char *str, *buf;
 
+       if (!cmdline)
+               return EFI_SUCCESS;
+
+       len = strlen(cmdline) + 1;
        status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, len, (void **)&buf);
        if (status != EFI_SUCCESS)
                return status;