Skip to contentSkip to conversation

net: stmmac: dwc-qos-eth: use devm_kzalloc() for AXI data

PATCH Applied Russell King (Oracle) 3 participants 3 messages Mar 12, 2025 – Mar 19, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: stmmac: dwc-qos-eth: use devm_kzalloc() for AXI data

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")
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +3 -1
index bd4eb187f8c6..b5a7e05ab7a7 100644
@@ -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;
Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Russell King (Oracle)

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")

Andrew

#2 lore raw
In reply to Russell King (Oracle)
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

Quoted 9 lines · On Wed, 12 Mar 2025 19:43:09 +0000 you wrote:

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")

[...]

Here is the summary with links:
- [net] net: stmmac: dwc-qos-eth: use devm_kzalloc() for AXI data

    https://git.kernel.org/netdev/net/c/c9cb135bc604

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html