linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: UNGLinuxDriver@microchip.com, vladimir.oltean@nxp.com,
	claudiu.manoil@nxp.com, davem@davemloft.net, kuba@kernel.org,
	andrew@lunn.ch, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] net: mscc: ocelot: Fix a resource leak in the error handling path of the probe function
Date: Mon, 14 Dec 2020 23:54:38 +0100	[thread overview]
Message-ID: <20201214225438.GY1781038@piout.net> (raw)
In-Reply-To: <20201213114838.126922-1-christophe.jaillet@wanadoo.fr>

On 13/12/2020 12:48:38+0100, Christophe JAILLET wrote:
> In case of error after calling 'ocelot_init()', it must be undone by a
> corresponding 'ocelot_deinit()' call, as already done in the remove
> function.
> 
> Fixes: a556c76adc05 ("net: mscc: Add initial Ocelot switch support")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

> ---
>  drivers/net/ethernet/mscc/ocelot_vsc7514.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
> index 1e7729421a82..9cf2bc5f4289 100644
> --- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c
> +++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
> @@ -1267,7 +1267,7 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
>  
>  	err = mscc_ocelot_init_ports(pdev, ports);
>  	if (err)
> -		goto out_put_ports;
> +		goto out_ocelot_deinit;
>  
>  	if (ocelot->ptp) {
>  		err = ocelot_init_timestamp(ocelot, &ocelot_ptp_clock_info);
> @@ -1282,8 +1282,14 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
>  	register_switchdev_notifier(&ocelot_switchdev_nb);
>  	register_switchdev_blocking_notifier(&ocelot_switchdev_blocking_nb);
>  
> +	of_node_put(ports);
> +
>  	dev_info(&pdev->dev, "Ocelot switch probed\n");
>  
> +	return 0;
> +
> +out_ocelot_deinit:
> +	ocelot_deinit(ocelot);
>  out_put_ports:
>  	of_node_put(ports);
>  	return err;
> -- 
> 2.27.0
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  parent reply	other threads:[~2020-12-14 22:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-13 11:48 [PATCH] net: mscc: ocelot: Fix a resource leak in the error handling path of the probe function Christophe JAILLET
2020-12-14 11:48 ` Dan Carpenter
2020-12-14 20:00   ` Christophe JAILLET
2020-12-14 20:00     ` Christophe JAILLET
2020-12-14 22:54 ` Alexandre Belloni [this message]
2020-12-16 19:20 ` patchwork-bot+netdevbpf

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=20201214225438.GY1781038@piout.net \
    --to=alexandre.belloni@bootlin.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vladimir.oltean@nxp.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;
as well as URLs for NNTP newsgroup(s).