All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Garry <john.garry@huawei.com>
To: Huang Zijiang <huang.zijiang@zte.com.cn>, <yisen.zhuang@huawei.com>
Cc: <salil.mehta@huawei.com>, <davem@davemloft.net>,
	<lipeng321@huawei.com>, <liuyonglong@huawei.com>,
	<yuehaibing@huawei.com>, <keescook@chromium.org>,
	<wangxi11@huawei.com>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <wang.yi59@zte.com.cn>,
	Linuxarm <linuxarm@huawei.com>
Subject: Re: [PATCH] net: hns: Fix object reference leaks in hns_dsaf_roce_reset()
Date: Fri, 15 Feb 2019 10:52:11 +0000	[thread overview]
Message-ID: <b20d235c-779c-77bd-e69f-2d63ffd79ec1@huawei.com> (raw)
In-Reply-To: <1550126505-28394-1-git-send-email-huang.zijiang@zte.com.cn>

On 14/02/2019 06:41, Huang Zijiang wrote:
> The of_find_device_by_node() takes a reference to the underlying device
> structure, we should release that reference.

of_find_device_by_node() is not called for every path, so is this change 
proper:

	/* find the platform device corresponding to fwnode */
	if (is_of_node(dsaf_fwnode)) {
		pdev = of_find_device_by_node(to_of_node(dsaf_fwnode));
	} else if (is_acpi_device_node(dsaf_fwnode)) {
		pdev = hns_dsaf_find_platform_device(dsaf_fwnode);
	} else {
		pr_err("fwnode is neither OF or ACPI type\n");
		return -EINVAL;
	}

	/* check if we were a success in fetching pdev */
	if (!pdev) {
		pr_err("couldn't find platform device for node\n");
		return -ENODEV;
	}

	/* retrieve the dsaf_device from the driver data */
	dsaf_dev = dev_get_drvdata(&pdev->dev);
	if (!dsaf_dev) {
		dev_err(&pdev->dev, "dsaf_dev is NULL\n");
		return -ENODEV;
	}

John

>
> Signed-off-by: Huang Zijiang <huang.zijiang@zte.com.cn>
> ---
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> index 14d7ec7..697d929 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> @@ -3081,6 +3081,7 @@ int hns_dsaf_roce_reset(struct fwnode_handle *dsaf_fwnode, bool dereset)
>  	dsaf_dev = dev_get_drvdata(&pdev->dev);
>  	if (!dsaf_dev) {
>  		dev_err(&pdev->dev, "dsaf_dev is NULL\n");
> +		put_device(&pdev->dev);
>  		return -ENODEV;
>  	}
>
> @@ -3088,6 +3089,7 @@ int hns_dsaf_roce_reset(struct fwnode_handle *dsaf_fwnode, bool dereset)
>  	if (AE_IS_VER1(dsaf_dev->dsaf_ver)) {
>  		dev_err(dsaf_dev->dev, "%s v1 chip doesn't support RoCE!\n",
>  			dsaf_dev->ae_dev.name);
> +		put_device(&pdev->dev);
>  		return -ENODEV;
>  	}
>
>



  parent reply	other threads:[~2019-02-15 10:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-14  6:41 [PATCH] net: hns: Fix object reference leaks in hns_dsaf_roce_reset() Huang Zijiang
2019-02-14 17:29 ` David Miller
2019-02-15 10:52 ` John Garry [this message]
2019-02-15 11:25   ` Salil Mehta
2019-02-15 12:00     ` John Garry
2019-02-18 17:54       ` Salil Mehta

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=b20d235c-779c-77bd-e69f-2d63ffd79ec1@huawei.com \
    --to=john.garry@huawei.com \
    --cc=davem@davemloft.net \
    --cc=huang.zijiang@zte.com.cn \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=lipeng321@huawei.com \
    --cc=liuyonglong@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=salil.mehta@huawei.com \
    --cc=wang.yi59@zte.com.cn \
    --cc=wangxi11@huawei.com \
    --cc=yisen.zhuang@huawei.com \
    --cc=yuehaibing@huawei.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.