summaryrefslogtreecommitdiff
path: root/drivers/firmware/efi
diff options
context:
space:
mode:
authorGuilherme G. Piccoli <gpiccoli@igalia.com>2022-09-09 22:42:14 +0300
committerArd Biesheuvel <ardb@kernel.org>2022-09-20 19:42:55 +0300
commit7da5b13dccd99cfdc42940fc7adcb88647023292 (patch)
treeae56aa7020ffcb03305f147bac40d3841aa3e202 /drivers/firmware/efi
parent9cb636b5f6a8cc6d1b50809ec8f8d33ae0c84c95 (diff)
downloadlinux-7da5b13dccd99cfdc42940fc7adcb88647023292.tar.xz
efi: efibc: Guard against allocation failure
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>
Diffstat (limited to 'drivers/firmware/efi')
-rw-r--r--drivers/firmware/efi/efibc.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/firmware/efi/efibc.c b/drivers/firmware/efi/efibc.c
index 8ced7af8e56d..4f9fb086eab7 100644
--- a/drivers/firmware/efi/efibc.c
+++ b/drivers/firmware/efi/efibc.c
@@ -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';