]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
PCI: tegra: Fix devm_kcalloc() argument order for port->phys allocation
authorAlok Tiwari <alok.a.tiwari@oracle.com>
Tue, 19 Aug 2025 15:04:08 +0000 (08:04 -0700)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 3 Sep 2025 20:41:02 +0000 (15:41 -0500)
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.

Fixes: 6fe7c187e026 ("PCI: tegra: Support per-lane PHYs")
Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
[mani: added Fixes tag]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250819150436.3105973-1-alok.a.tiwari@oracle.com
drivers/pci/controller/pci-tegra.c

index 467ddc701adce28c5edeb6d1b423ce56068f069a..bb88767a3797953a039bb152191a3dbb606d8b8f 100644 (file)
@@ -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;