net: ethernet: stmicro: stmmac: fix possible memory leak in __stmmac_open
Subsystems (5)
PATCH 1/1 net: ethernet: stmicro: stmmac: fix possible memory leak in __stmmac_open
Fix a possible memory leak in __stmmac_open when stmmac_init_phy fails. It's also needed to free everything allocated by stmmac_setup_dma_desc and not just the dma_conf struct.
Correctly call free_dma_desc_resources on the new dma_conf passed to __stmmac_open on error.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -1
@@ -3877,10 +3877,10 @@ static int __stmmac_open(struct net_device *dev,stmmac_hw_teardown (dev); init_error: -free_dma_desc_resources (priv, &priv->dma_conf);phylink_disconnect_phy (priv->phylink); init_phy_error:pm_runtime_put (priv->device); +free_dma_desc_resources (priv, dma_conf);return ret; }
Signature · 1 line
2.40.1
Quoted 20 lines · Christian Marangi
Fix a possible memory leak in
__stmmac_openwhenstmmac_init_phyfails. It's also needed to free everything allocated bystmmac_setup_dma_descand not just thedma_confstruct.Correctly call
free_dma_desc_resourceson the newdma_confpassed to__stmmac_openon error.Reported-by Jose Abreu <[email protected]>Fixes ba39b344e924 ("net: ethernet: stmicro: stmmac: generate stmmac dma conf before open")Signed-off-by Christian Marangi <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int __stmmac_open(struct net_device *dev, · line 3883
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -3877,10 +3877,10 @@ static int __stmmac_open(struct net_device *dev,stmmac_hw_teardown (dev); init_error: -free_dma_desc_resources (priv, &priv->dma_conf);phylink_disconnect_phy (priv->phylink); init_phy_error:pm_runtime_put (priv->device); +free_dma_desc_resources (priv, dma_conf);
Hi Christian,
Are these resources allocated by the caller?
If so, perhaps it would be clearer if a symmetric approach was taken and the caller handled freeing them on error.
Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0return ret; }Signature · 1 line
2.40.1
Quoted 32 lines · Simon Horman
Quoted 20 lines · Christian Marangi
Fix a possible memory leak in
__stmmac_openwhenstmmac_init_phyfails. It's also needed to free everything allocated bystmmac_setup_dma_descand not just thedma_confstruct.Correctly call
free_dma_desc_resourceson the newdma_confpassed to__stmmac_openon error.Reported-by Jose Abreu <[email protected]>Fixes ba39b344e924 ("net: ethernet: stmicro: stmmac: generate stmmac dma conf before open")Signed-off-by Christian Marangi <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int __stmmac_open(struct net_device *dev, · line 3883
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -3877,10 +3877,10 @@ static int __stmmac_open(struct net_device *dev,stmmac_hw_teardown (dev); init_error: -free_dma_desc_resources (priv, &priv->dma_conf);phylink_disconnect_phy (priv->phylink); init_phy_error:pm_runtime_put (priv->device); +free_dma_desc_resources (priv, dma_conf);Hi Christian,
Quoted 4 lines
Are these resources allocated by the caller?
If so, perhaps it would be clearer if a symmetric approach was taken and the caller handled freeing them on error.
Yes, they are. Handling in the caller would require some additional delta to this and some duplicated code but if preferred I can implement it. I can provide a v2 shortly if it's ok and you prefer this implementation.
Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0return ret; }Signature · 1 line
2.40.1
Signature · 1 line
Ansuel
Quoted 38 lines · Christian Marangi
Quoted 32 lines · Simon Horman
Quoted 20 lines · Christian Marangi
Fix a possible memory leak in
__stmmac_openwhenstmmac_init_phyfails. It's also needed to free everything allocated bystmmac_setup_dma_descand not just thedma_confstruct.Correctly call
free_dma_desc_resourceson the newdma_confpassed to__stmmac_openon error.Reported-by Jose Abreu <[email protected]>Fixes ba39b344e924 ("net: ethernet: stmicro: stmmac: generate stmmac dma conf before open")Signed-off-by Christian Marangi <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int __stmmac_open(struct net_device *dev, · line 3883
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -3877,10 +3877,10 @@ static int __stmmac_open(struct net_device *dev,stmmac_hw_teardown (dev); init_error: -free_dma_desc_resources (priv, &priv->dma_conf);phylink_disconnect_phy (priv->phylink); init_phy_error:pm_runtime_put (priv->device); +free_dma_desc_resources (priv, dma_conf);Hi Christian,
Quoted 4 lines
Are these resources allocated by the caller?
If so, perhaps it would be clearer if a symmetric approach was taken and the caller handled freeing them on error.
Quoted 4 lines
Yes, they are. Handling in the caller would require some additional delta to this and some duplicated code but if preferred I can implement it. I can provide a v2 shortly if it's ok and you prefer this implementation.
Thanks, I think that would be best,
unless the new delta is enormous for some reason.
Signature · 1 line
pw-bot: cr