lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <g5qqewwjflr7uzuhwcjbbykjj2lf2civ5vcltehgddjpc5abv5@2abp2b4r6kyg>
Date: Tue, 19 Aug 2025 13:02:52 -0700
From: David Box <david.e.box@...ux.intel.com>
To: Qianfeng Rong <rongqianfeng@...o.com>
Cc: Rajneesh Bhardwaj <irenic.rajneesh@...il.com>, 
	David E Box <david.e.box@...el.com>, Hans de Goede <hansg@...nel.org>, 
	Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>, platform-driver-x86@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] platform/x86/intel/pmc: use kcalloc() instead of
 kzalloc()

On Tue, Aug 19, 2025 at 09:51:55PM +0800, Qianfeng Rong wrote:
> Replace devm_kzalloc() with devm_kcalloc() in pmc_core_get_tgl_lpm_reqs().
> As noted in the kernel documentation [1], open-coded multiplication in
> allocator arguments is discouraged because it can lead to integer
> overflow.
> 
> Using devm_kcalloc() provides built-in overflow protection, making the
> memory allocation safer when calculating the allocation size compared
> to explicit multiplication.
> 
> [1]: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments
> 
> Signed-off-by: Qianfeng Rong <rongqianfeng@...o.com>

Acked-by: David E. Box <david.e.box@...el.com>

Thanks

> ---
>  drivers/platform/x86/intel/pmc/tgl.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel/pmc/tgl.c b/drivers/platform/x86/intel/pmc/tgl.c
> index 02e731ed3391..fc5b4cacc1c6 100644
> --- a/drivers/platform/x86/intel/pmc/tgl.c
> +++ b/drivers/platform/x86/intel/pmc/tgl.c
> @@ -273,8 +273,8 @@ void pmc_core_get_tgl_lpm_reqs(struct platform_device *pdev)
>  
>  	addr = (u32 *)out_obj->buffer.pointer;
>  
> -	lpm_req_regs = devm_kzalloc(&pdev->dev, lpm_size * sizeof(u32),
> -				     GFP_KERNEL);
> +	lpm_req_regs = devm_kcalloc(&pdev->dev, lpm_size, sizeof(u32),
> +				    GFP_KERNEL);
>  	if (!lpm_req_regs)
>  		goto free_acpi_obj;
>  
> -- 
> 2.34.1
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ