net: ethernet: stmicro: stmmac: fix possible memory leak in __stmmac_open
authorChristian Marangi <ansuelsmth@gmail.com>
Wed, 14 Jun 2023 09:17:14 +0000 (11:17 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 15 Jun 2023 22:02:04 +0000 (15:02 -0700)
commit30134b7c47bd28fdb4db4d12aef824e0579cfee4
treeafc5731b0e6d2eae70ef4bb0748e87c4c42120f2
parent44194cb1b6045dea33ae9a0d54fb7e7cd93a2e09
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.

Drop free_dma_desc_resources from __stmmac_open and correctly call
free_dma_desc_resources on each user of __stmmac_open on error.

Reported-by: Jose Abreu <Jose.Abreu@synopsys.com>
Fixes: ba39b344e924 ("net: ethernet: stmicro: stmmac: generate stmmac dma conf before open")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Cc: stable@vger.kernel.org
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Reviewed-by: Jose Abreu <Jose.Abreu@synopsys.com>
Link: https://lore.kernel.org/r/20230614091714.15912-1-ansuelsmth@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c