[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <04d65bd7-a6b2-bb14-fd69-632542ae9e86@wanadoo.fr>
Date: Sat, 10 Sep 2022 06:56:43 +0200
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: "Guilherme G. Piccoli" <gpiccoli@...lia.com>,
linux-efi@...r.kernel.org
Cc: ardb@...nel.org, linux-kernel@...r.kernel.org,
kernel-dev@...lia.com, kernel@...ccoli.net,
matt@...eblueprint.co.uk, mjg59@...f.ucam.org
Subject: Re: [PATCH V2] efi: efibc: Guard against allocation failure
Le 09/09/2022 à 21:42, Guilherme G. Piccoli a écrit :
> 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@...lia.com>
> ---
>
> V2:
> * Rebased against 6.0-rc4;
> * Dropped from the original series [0].
>
> [0] https://lore.kernel.org/linux-efi/20220729194532.228403-1-gpiccoli@igalia.com/
>
>
> drivers/firmware/efi/efibc.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> 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);
Hi,
even if mostly useless in this case, kmalloc_array()?
Or certainly maybe even better, kstrndup()?
CJ
> + 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';
Powered by blists - more mailing lists