All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Qing Wang <wangqing@vivo.com>
Cc: Madalin Bucur <madalin.bucur@nxp.com>,
	"David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org
Subject: Re: [PATCH] ethernet: fman: add missing put_device() call in mac_probe()
Date: Wed, 8 Dec 2021 18:29:49 -0800	[thread overview]
Message-ID: <20211208182949.69733b8b@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> (raw)
In-Reply-To: <1638881761-3262-1-git-send-email-wangqing@vivo.com>

On Tue,  7 Dec 2021 04:56:00 -0800 Qing Wang wrote:
> From: Wang Qing <wangqing@vivo.com>
> 
> of_find_device_by_node() takes a reference to the embedded struct device 
> which needs to be dropped when error return.
> 
> Add a jump target to fix the exception handling for this 
> function implementation.
> 
> Signed-off-by: Wang Qing <wangqing@vivo.com>

The entire mac_dev->port[] handling seems entirely pointless and leaky. 
Nothing ever reads the mac_dev->port array. We should remove it
completely.

> diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c
> index d9fc5c4..5180121
> --- a/drivers/net/ethernet/freescale/fman/mac.c
> +++ b/drivers/net/ethernet/freescale/fman/mac.c
> @@ -668,7 +668,7 @@ static int mac_probe(struct platform_device *_of_dev)
>  	if (err) {
>  		dev_err(dev, "failed to read cell-index for %pOF\n", dev_node);
>  		err = -EINVAL;
> -		goto _return_of_node_put;
> +		goto _return_of_put_device;
>  	}
>  	/* cell-index 0 => FMan id 1 */
>  	fman_id = (u8)(val + 1);
> @@ -677,7 +677,7 @@ static int mac_probe(struct platform_device *_of_dev)
>  	if (!priv->fman) {
>  		dev_err(dev, "fman_bind(%pOF) failed\n", dev_node);
>  		err = -ENODEV;
> -		goto _return_of_node_put;
> +		goto _return_of_put_device;
>  	}
>  
>  	of_node_put(dev_node);
> @@ -758,7 +758,7 @@ static int mac_probe(struct platform_device *_of_dev)
>  			dev_err(dev, "of_find_device_by_node(%pOF) failed\n",
>  				dev_node);
>  			err = -EINVAL;
> -			goto _return_of_node_put;
> +			goto _return_of_put_device;
>  		}
>  
>  		mac_dev->port[i] = fman_port_bind(&of_dev->dev);
> @@ -766,7 +766,7 @@ static int mac_probe(struct platform_device *_of_dev)
>  			dev_err(dev, "dev_get_drvdata(%pOF) failed\n",
>  				dev_node);
>  			err = -EINVAL;
> -			goto _return_of_node_put;
> +			goto _return_of_put_device;
>  		}
>  		of_node_put(dev_node);
>  	}
> @@ -863,6 +863,8 @@ static int mac_probe(struct platform_device *_of_dev)
>  
>  	goto _return;
>  
> +_return_of_put_device:
> +	put_device(&of_dev->dev);
>  _return_of_node_put:
>  	of_node_put(dev_node);
>  _return_of_get_parent:


      reply	other threads:[~2021-12-09  2:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-07 12:56 [PATCH] ethernet: fman: add missing put_device() call in mac_probe() Qing Wang
2021-12-09  2:29 ` Jakub Kicinski [this message]

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=20211208182949.69733b8b@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=madalin.bucur@nxp.com \
    --cc=netdev@vger.kernel.org \
    --cc=wangqing@vivo.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.