Netdev List
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>,
	alexandre.torgue@foss.st.com, joabreu@synopsys.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] net: stmmac: call stmmac_remove_config_dt() in error paths in stmmac_probe_config_dt()
Date: Tue, 17 Dec 2024 11:58:40 +0100	[thread overview]
Message-ID: <21d372a2-479a-4ea5-a60a-3693b8f0e8ba@kernel.org> (raw)
In-Reply-To: <20241217033243.3144184-1-joe@pf.is.s.u-tokyo.ac.jp>

On 17/12/2024 04:32, Joe Hattori wrote:
> Current implementation of stmmac_probe_config_dt() does not release the
> OF node reference obtained by of_parse_phandle() when stmmac_dt_phy()
> fails, thus call stmmac_remove_config_dt(). The error_hw_init and
> error_pclk_get labels can be removed as just calling
> stmmac_remove_config_dt() suffices. Also, remove the first argument of
> stmmac_remove_config_dt() as it is not used.
> 
> This bug was found by an experimental static analysis tool that I am
> developing.
> 
> Fixes: 4838a5405028 ("net: stmmac: Fix wrapper drivers not detecting PHY")
> Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
> ---
>  .../ethernet/stmicro/stmmac/stmmac_platform.c | 37 +++++++------------
>  1 file changed, 13 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> index 3ac32444e492..4f1a9f7aae6e 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> @@ -407,13 +407,11 @@ static int stmmac_of_get_mac_mode(struct device_node *np)
>  
>  /**
>   * stmmac_remove_config_dt - undo the effects of stmmac_probe_config_dt()
> - * @pdev: platform_device structure
>   * @plat: driver data platform structure
>   *
>   * Release resources claimed by stmmac_probe_config_dt().
>   */
> -static void stmmac_remove_config_dt(struct platform_device *pdev,
> -				    struct plat_stmmacenet_data *plat)
> +static void stmmac_remove_config_dt(struct plat_stmmacenet_data *plat)
>  {
>  	clk_disable_unprepare(plat->stmmac_clk);
>  	clk_disable_unprepare(plat->pclk);
> @@ -436,7 +434,6 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)
>  	struct plat_stmmacenet_data *plat;
>  	struct stmmac_dma_cfg *dma_cfg;
>  	int phy_mode;
> -	void *ret;
>  	int rc;
>  
>  	plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
> @@ -490,8 +487,10 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)
>  		dev_warn(&pdev->dev, "snps,phy-addr property is deprecated\n");
>  
>  	rc = stmmac_mdio_setup(plat, np, &pdev->dev);
> -	if (rc)
> +	if (rc) {
> +		stmmac_remove_config_dt(plat);
>  		return ERR_PTR(rc);
You now double unprepare the clocks. This is either buggy or just
confusing (assuming clocks are NULL).

Best regards,
Krzysztof

  reply	other threads:[~2024-12-17 10:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-17  3:32 [PATCH] net: stmmac: call stmmac_remove_config_dt() in error paths in stmmac_probe_config_dt() Joe Hattori
2024-12-17 10:58 ` Krzysztof Kozlowski [this message]
2024-12-18  3:24   ` Joe Hattori
2024-12-17 11:27 ` Dan Carpenter
2024-12-18  3:27   ` Joe Hattori

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=21d372a2-479a-4ea5-a60a-3693b8f0e8ba@kernel.org \
    --to=krzk@kernel.org \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=joabreu@synopsys.com \
    --cc=joe@pf.is.s.u-tokyo.ac.jp \
    --cc=kuba@kernel.org \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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