]> git.baikalelectronics.ru Git - kernel.git/commitdiff
efi: efibc: Guard against allocation failure
authorGuilherme G. Piccoli <gpiccoli@igalia.com>
Fri, 9 Sep 2022 19:42:14 +0000 (16:42 -0300)
committerArd Biesheuvel <ardb@kernel.org>
Tue, 20 Sep 2022 16:42:55 +0000 (18:42 +0200)
There is a single kmalloc in this driver, and it's not currently
guarded against allocation failure. Do it here by just bailing-out
the reboot handler, in case this tentative allocation fails.

Fixes: 416581e48679 ("efi: efibc: avoid efivar API for setting variables")
Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/efibc.c

index 8ced7af8e56d28d0dffe40e84506e6a88dd60b54..4f9fb086eab7b0e22252d22e59e5aae55865322d 100644 (file)
@@ -48,6 +48,9 @@ static int efibc_reboot_notifier_call(struct notifier_block *notifier,
                return NOTIFY_DONE;
 
        wdata = kmalloc(MAX_DATA_LEN * sizeof(efi_char16_t), GFP_KERNEL);
+       if (!wdata)
+               return NOTIFY_DONE;
+
        for (l = 0; l < MAX_DATA_LEN - 1 && str[l] != '\0'; l++)
                wdata[l] = str[l];
        wdata[l] = L'\0';