From: Siddharth Vadapalli <s-vadapalli@ti.com>
To: Qianfeng Rong <rongqianfeng@vivo.com>
Cc: "Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Niklas Cassel" <cassel@kernel.org>,
"Kishon Vijay Abraham I" <kishon@kernel.org>,
"Siddharth Vadapalli" <s-vadapalli@ti.com>,
"Sergio Paracuellos" <sergio.paracuellos@gmail.com>,
"Hans Zhang" <18255117159@163.com>,
"Jiri Slaby (SUSE)" <jirislaby@kernel.org>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI: keystone: Use kcalloc() instead of kzalloc()
Date: Tue, 19 Aug 2025 15:19:13 +0530 [thread overview]
Message-ID: <f5fb6c50-7576-4b75-bbed-7989f4718daf@ti.com> (raw)
In-Reply-To: <20250819085917.539798-1-rongqianfeng@vivo.com>
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@vivo.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.
next prev parent reply other threads:[~2025-08-19 9:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-19 8:59 Qianfeng Rong
2025-08-19 9:49 ` Siddharth Vadapalli [this message]
2025-08-19 9:53 ` Qianfeng Rong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f5fb6c50-7576-4b75-bbed-7989f4718daf@ti.com \
--to=s-vadapalli@ti.com \
--cc=18255117159@163.com \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=jirislaby@kernel.org \
--cc=kishon@kernel.org \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=robh@kernel.org \
--cc=rongqianfeng@vivo.com \
--cc=sergio.paracuellos@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®