From: Simon Horman <simon.horman@corigine.com>
To: Christian Marangi <ansuelsmth@gmail.com>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Jose Abreu <joabreu@synopsys.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Russell King <linux@armlinux.org.uk>,
netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Jose Abreu <Jose.Abreu@synopsys.com>,
stable@vger.kernel.org
Subject: Re: [net PATCH] net: ethernet: stmicro: stmmac: fix possible memory leak in __stmmac_open
Date: Wed, 14 Jun 2023 16:55:10 +0200 [thread overview]
Message-ID: <ZInUzhOZ/3TGSQl9@corigine.com> (raw)
In-Reply-To: <20230614073241.6382-1-ansuelsmth@gmail.com>
On Wed, Jun 14, 2023 at 09:32:41AM +0200, Christian Marangi wrote:
> 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.
>
> 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
> ---
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index fa07b0d50b46..0966ab86fde2 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -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.
> return ret;
> }
>
> --
> 2.40.1
>
>
next prev parent reply other threads:[~2023-06-14 14:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-14 7:32 [net PATCH] net: ethernet: stmicro: stmmac: fix possible memory leak in __stmmac_open Christian Marangi
2023-06-14 14:55 ` Simon Horman [this message]
2023-06-14 8:18 ` Christian Marangi
2023-06-14 15:41 ` Simon Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZInUzhOZ/3TGSQl9@corigine.com \
--to=simon.horman@corigine.com \
--cc=Jose.Abreu@synopsys.com \
--cc=alexandre.torgue@foss.st.com \
--cc=ansuelsmth@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=joabreu@synopsys.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux@armlinux.org.uk \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=peppe.cavallaro@st.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox