diff mbox series

efi: efibc: change kmalloc(size * count, ...) to kmalloc_array()

Message ID 20250308-efibc-kmalloc_array-v1-1-7bfc4013986f@ethancedwards.com (mailing list archive)
State In Next
Commit ac2efaa8455021ce1e6216457684d60a9e2c77fd
Headers show
Series efi: efibc: change kmalloc(size * count, ...) to kmalloc_array() | expand

Commit Message

Ethan Carter Edwards March 9, 2025, 1:27 a.m. UTC
Open coded arithmetic in allocator arguments is discouraged. Helper
functions like kcalloc or, in this case, kmalloc_array are preferred.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments

Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
---
 drivers/firmware/efi/efibc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


---
base-commit: 0a2f889128969dab41861b6e40111aa03dc57014
change-id: 20250308-efibc-kmalloc_array-ba78097a0708

Best regards,

Comments

Ard Biesheuvel March 10, 2025, 5:23 p.m. UTC | #1
On Sun, 9 Mar 2025 at 02:27, Ethan Carter Edwards
<ethan@ethancedwards.com> wrote:
>
> Open coded arithmetic in allocator arguments is discouraged. Helper
> functions like kcalloc or, in this case, kmalloc_array are preferred.
>
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments
>
> Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
> ---
>  drivers/firmware/efi/efibc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/efi/efibc.c b/drivers/firmware/efi/efibc.c
> index 4f9fb086eab7b0e22252d22e59e5aae55865322d..0a7c764dcc614fbba3cbcd94183dc07939837a03 100644
> --- a/drivers/firmware/efi/efibc.c
> +++ b/drivers/firmware/efi/efibc.c
> @@ -47,7 +47,7 @@ static int efibc_reboot_notifier_call(struct notifier_block *notifier,
>         if (ret || !data)
>                 return NOTIFY_DONE;
>
> -       wdata = kmalloc(MAX_DATA_LEN * sizeof(efi_char16_t), GFP_KERNEL);
> +       wdata = kmalloc_array(MAX_DATA_LEN, sizeof(efi_char16_t), GFP_KERNEL);
>         if (!wdata)
>                 return NOTIFY_DONE;
>
>
> ---
> base-commit: 0a2f889128969dab41861b6e40111aa03dc57014
> change-id: 20250308-efibc-kmalloc_array-ba78097a0708
>

Queued up in efi/next, thanks.
diff mbox series

Patch

diff --git a/drivers/firmware/efi/efibc.c b/drivers/firmware/efi/efibc.c
index 4f9fb086eab7b0e22252d22e59e5aae55865322d..0a7c764dcc614fbba3cbcd94183dc07939837a03 100644
--- a/drivers/firmware/efi/efibc.c
+++ b/drivers/firmware/efi/efibc.c
@@ -47,7 +47,7 @@  static int efibc_reboot_notifier_call(struct notifier_block *notifier,
 	if (ret || !data)
 		return NOTIFY_DONE;
 
-	wdata = kmalloc(MAX_DATA_LEN * sizeof(efi_char16_t), GFP_KERNEL);
+	wdata = kmalloc_array(MAX_DATA_LEN, sizeof(efi_char16_t), GFP_KERNEL);
 	if (!wdata)
 		return NOTIFY_DONE;