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: <f5fb6c50-7576-4b75-bbed-7989f4718daf@ti.com>
Date: Tue, 19 Aug 2025 15:19:13 +0530
From: Siddharth Vadapalli <s-vadapalli@...com>
To: Qianfeng Rong <rongqianfeng@...o.com>
CC: Lorenzo Pieralisi <lpieralisi@...nel.org>,
        Krzysztof
 WilczyƄski <kwilczynski@...nel.org>,
        Manivannan Sadhasivam
	<mani@...nel.org>,
        Rob Herring <robh@...nel.org>, Bjorn Helgaas
	<bhelgaas@...gle.com>,
        Niklas Cassel <cassel@...nel.org>,
        Kishon Vijay
 Abraham I <kishon@...nel.org>,
        Siddharth Vadapalli <s-vadapalli@...com>,
        Sergio Paracuellos <sergio.paracuellos@...il.com>,
        Hans Zhang
	<18255117159@....com>,
        "Jiri Slaby (SUSE)" <jirislaby@...nel.org>,
        <linux-pci@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] PCI: keystone: Use kcalloc() instead of kzalloc()

On Tue, Aug 19, 2025 at 04:59:15PM +0800, Qianfeng Rong wrote:

Hello,

> Replace calls of devm_kzalloc() with devm_kcalloc() in ks_pcie_probe() for
> safer memory allocation with built-in overflow protection.

Please add more details by referring to:
https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments
and stating that multiplication could lead to an overflow and isn't safe
when it is used to calculate the size of allocation.

> 
> Signed-off-by: Qianfeng Rong <rongqianfeng@...o.com>
> ---
>  drivers/pci/controller/dwc/pci-keystone.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c
> index 7d7aede54ed3..3d10e1112131 100644
> --- a/drivers/pci/controller/dwc/pci-keystone.c
> +++ b/drivers/pci/controller/dwc/pci-keystone.c
> @@ -1212,11 +1212,11 @@ static int ks_pcie_probe(struct platform_device *pdev)
>  	if (ret)
>  		num_lanes = 1;
>  
> -	phy = devm_kzalloc(dev, sizeof(*phy) * num_lanes, GFP_KERNEL);
> +	phy = devm_kcalloc(dev, num_lanes, sizeof(*phy), GFP_KERNEL);
>  	if (!phy)
>  		return -ENOMEM;
>  
> -	link = devm_kzalloc(dev, sizeof(*link) * num_lanes, GFP_KERNEL);
> +	link = devm_kcalloc(dev, num_lanes, sizeof(*link), GFP_KERNEL);
>  	if (!link)
>  		return -ENOMEM;

Regards,
Siddharth.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ