]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: stmmac: tegra: Properly allocate clock bulk data
authorThierry Reding <treding@nvidia.com>
Wed, 26 Jul 2023 16:32:00 +0000 (18:32 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sat, 29 Jul 2023 15:59:51 +0000 (16:59 +0100)
The clock data is an array of struct clk_bulk_data, so make sure to
allocate enough memory.

Fixes: d8ca113724e7 ("net: stmmac: tegra: Add MGBE support")
Signed-off-by: Thierry Reding <treding@nvidia.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c

index f8367c5b490baa64d01ac753ed5abf733defbab8..fbb0ccf84afc46727ee013cad7fc684300c96453 100644 (file)
@@ -234,7 +234,8 @@ static int tegra_mgbe_probe(struct platform_device *pdev)
        res.addr = mgbe->regs;
        res.irq = irq;
 
-       mgbe->clks = devm_kzalloc(&pdev->dev, sizeof(*mgbe->clks), GFP_KERNEL);
+       mgbe->clks = devm_kcalloc(&pdev->dev, ARRAY_SIZE(mgbe_clks),
+                                 sizeof(*mgbe->clks), GFP_KERNEL);
        if (!mgbe->clks)
                return -ENOMEM;