]> www.infradead.org Git - users/hch/misc.git/commitdiff
net: stmmac: dwc-qos-eth: use devm_kzalloc() for AXI data
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Wed, 12 Mar 2025 19:43:09 +0000 (19:43 +0000)
committerPaolo Abeni <pabeni@redhat.com>
Wed, 19 Mar 2025 18:08:29 +0000 (19:08 +0100)
Everywhere else in the driver uses devm_kzalloc() when allocating the
AXI data, so there is no kfree() of this structure. However,
dwc-qos-eth uses kzalloc(), which leads to this memory being leaked.
Switch to use devm_kzalloc().

Fixes: d8256121a91a ("stmmac: adding new glue driver dwmac-dwc-qos-eth")
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/E1tsRyv-0064nU-O9@rmk-PC.armlinux.org.uk
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c

index bd4eb187f8c64aae68fa4e7395b4000984ac4d88..b5a7e05ab7a7e2c9c0bab52f29e7dadf4d292766 100644 (file)
@@ -46,7 +46,9 @@ static int dwc_eth_dwmac_config_dt(struct platform_device *pdev,
        u32 a_index = 0;
 
        if (!plat_dat->axi) {
-               plat_dat->axi = kzalloc(sizeof(struct stmmac_axi), GFP_KERNEL);
+               plat_dat->axi = devm_kzalloc(&pdev->dev,
+                                            sizeof(struct stmmac_axi),
+                                            GFP_KERNEL);
 
                if (!plat_dat->axi)
                        return -ENOMEM;