mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] PCI: tegra: fix devm_kcalloc argument order for port->phys allocation
@ 2025-08-19 15:04 Alok Tiwari
  2025-08-31 11:20 ` Manivannan Sadhasivam
  2025-08-31 11:25 ` Manivannan Sadhasivam
  0 siblings, 2 replies; 3+ messages in thread
From: Alok Tiwari @ 2025-08-19 15:04 UTC (permalink / raw)
  To: thierry.reding, lpieralisi, kwilczynski, mani, robh, bhelgaas,
	jonathanh, linux-tegra, linux-pci
  Cc: alok.a.tiwari, linux-kernel

Fix incorrect argument order in devm_kcalloc() when allocating
port->phys, The original call used sizeof(phy) as the number of
elements and port->lanes as the element size, which is reversed.
While this happens to produce the correct total allocation size with
current pointer size and lane counts, the argument order is wrong.

Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
---
 drivers/pci/controller/pci-tegra.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c
index 467ddc701adc..bb88767a3797 100644
--- a/drivers/pci/controller/pci-tegra.c
+++ b/drivers/pci/controller/pci-tegra.c
@@ -1344,7 +1344,7 @@ static int tegra_pcie_port_get_phys(struct tegra_pcie_port *port)
 	unsigned int i;
 	int err;
 
-	port->phys = devm_kcalloc(dev, sizeof(phy), port->lanes, GFP_KERNEL);
+	port->phys = devm_kcalloc(dev, port->lanes, sizeof(phy), GFP_KERNEL);
 	if (!port->phys)
 		return -ENOMEM;
 
-- 
2.50.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI: tegra: fix devm_kcalloc argument order for port->phys allocation
  2025-08-19 15:04 [PATCH] PCI: tegra: fix devm_kcalloc argument order for port->phys allocation Alok Tiwari
@ 2025-08-31 11:20 ` Manivannan Sadhasivam
  2025-08-31 11:25 ` Manivannan Sadhasivam
  1 sibling, 0 replies; 3+ messages in thread
From: Manivannan Sadhasivam @ 2025-08-31 11:20 UTC (permalink / raw)
  To: Alok Tiwari
  Cc: thierry.reding, lpieralisi, kwilczynski, robh, bhelgaas,
	jonathanh, linux-tegra, linux-pci, linux-kernel

On Tue, Aug 19, 2025 at 08:04:08AM GMT, Alok Tiwari wrote:
> Fix incorrect argument order in devm_kcalloc() when allocating
> port->phys, The original call used sizeof(phy) as the number of
> elements and port->lanes as the element size, which is reversed.
> While this happens to produce the correct total allocation size with
> current pointer size and lane counts, the argument order is wrong.
> 
> Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>

Missing Fixes tag. I'll add it while applying.

- Mani

> ---
>  drivers/pci/controller/pci-tegra.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c
> index 467ddc701adc..bb88767a3797 100644
> --- a/drivers/pci/controller/pci-tegra.c
> +++ b/drivers/pci/controller/pci-tegra.c
> @@ -1344,7 +1344,7 @@ static int tegra_pcie_port_get_phys(struct tegra_pcie_port *port)
>  	unsigned int i;
>  	int err;
>  
> -	port->phys = devm_kcalloc(dev, sizeof(phy), port->lanes, GFP_KERNEL);
> +	port->phys = devm_kcalloc(dev, port->lanes, sizeof(phy), GFP_KERNEL);
>  	if (!port->phys)
>  		return -ENOMEM;
>  
> -- 
> 2.50.1
> 

-- 
மணிவண்ணன் சதாசிவம்

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI: tegra: fix devm_kcalloc argument order for port->phys allocation
  2025-08-19 15:04 [PATCH] PCI: tegra: fix devm_kcalloc argument order for port->phys allocation Alok Tiwari
  2025-08-31 11:20 ` Manivannan Sadhasivam
@ 2025-08-31 11:25 ` Manivannan Sadhasivam
  1 sibling, 0 replies; 3+ messages in thread
From: Manivannan Sadhasivam @ 2025-08-31 11:25 UTC (permalink / raw)
  To: thierry.reding, lpieralisi, kwilczynski, robh, bhelgaas,
	jonathanh, linux-tegra, linux-pci, Alok Tiwari
  Cc: linux-kernel


On Tue, 19 Aug 2025 08:04:08 -0700, Alok Tiwari wrote:
> Fix incorrect argument order in devm_kcalloc() when allocating
> port->phys, The original call used sizeof(phy) as the number of
> elements and port->lanes as the element size, which is reversed.
> While this happens to produce the correct total allocation size with
> current pointer size and lane counts, the argument order is wrong.
> 
> 
> [...]

Applied, thanks!

[1/1] PCI: tegra: fix devm_kcalloc argument order for port->phys allocation
      commit: b69f898bf94b374a97d367459ff2fb52b4ab8829

Best regards,
-- 
Manivannan Sadhasivam <mani@kernel.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-08-31 11:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-19 15:04 [PATCH] PCI: tegra: fix devm_kcalloc argument order for port->phys allocation Alok Tiwari
2025-08-31 11:20 ` Manivannan Sadhasivam
2025-08-31 11:25 ` Manivannan Sadhasivam

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®