Skip to contentSkip to conversation

net: systemport: free dev before on error path

PATCH Applied Pan Bian 3 participants 3 messages Jan 20, 2021

Subsystems (3)
lore
Share & tools
lore

Pan Bian

author
#0 lore raw

PATCH 1/1 net: systemport: free dev before on error path

On the error path, it should goto the error handling label to free allocated memory rather than directly return.

Fixes 6328a126896e ("net: systemport: Manage Wake-on-LAN clock")
---
 drivers/net/ethernet/broadcom/bcmsysport.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bcmsysport.c +4 -2
index b1ae9eb8f247..0404aafd5ce5 100644
@@ -2503,8 +2503,10 @@ static int bcm_sysport_probe(struct platform_device *pdev)
 	priv = netdev_priv(dev);
 
 	priv->clk = devm_clk_get_optional(&pdev->dev, "sw_sysport");
-	if (IS_ERR(priv->clk))
-		return PTR_ERR(priv->clk);
+	if (IS_ERR(priv->clk)) {
+		ret = PTR_ERR(priv->clk);
+		goto err_free_netdev;
+	}
 
 	/* Allocate number of TX rings */
 	priv->tx_rings = devm_kcalloc(&pdev->dev, txq,
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Pan Bian

On the error path, it should goto the error handling label to free allocated memory rather than directly return.

Fixes 6328a126896e ("net: systemport: Manage Wake-on-LAN clock")

The change is correct, but not the Fixes tag, it should be:

Fixes 31bc72d97656 ("net: systemport: fetch and use clock resources")
Signature · 1 line
Florian
maintainer Applied
#2 lore raw
Quoted 4 lines · On Tue, 19 Jan 2021 21:07:10 -0800 Florian Fainelli wrote:
Quoted 3 lines · Pan Bian

On the error path, it should goto the error handling label to free allocated memory rather than directly return.

Quoted 8 lines
Quoted 2 lines
Fixes 6328a126896e ("net: systemport: Manage Wake-on-LAN clock")

The change is correct, but not the Fixes tag, it should be:

Fixes 31bc72d97656 ("net: systemport: fetch and use clock resources")

Applied, thank you!