All of lore.kernel.org
 help / color / mirror / Atom feed
From: Salil Mehta <salil.mehta@huawei.com>
To: John Garry <john.garry@huawei.com>,
	Huang Zijiang <huang.zijiang@zte.com.cn>,
	"Zhuangyuzeng (Yisen)" <yisen.zhuang@huawei.com>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"lipeng (Y)" <lipeng321@huawei.com>,
	liuyonglong <liuyonglong@huawei.com>,
	yuehaibing <yuehaibing@huawei.com>,
	"keescook@chromium.org" <keescook@chromium.org>,
	"wangxi (M)" <wangxi11@huawei.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"wang.yi59@zte.com.cn" <wang.yi59@zte.com.cn>,
	Linuxarm <linuxarm@huawei.com>
Subject: RE: [PATCH] net: hns: Fix object reference leaks in hns_dsaf_roce_reset()
Date: Mon, 18 Feb 2019 17:54:08 +0000	[thread overview]
Message-ID: <961cf1cfaf05448092e517f4058ea062@huawei.com> (raw)
In-Reply-To: <4ca251e6-22a1-a792-bb64-2498d8cb6fcd@huawei.com>

> From: John Garry
> Sent: Friday, February 15, 2019 12:00 PM
> 
> On 15/02/2019 11:25, Salil Mehta wrote:
> >> From: John Garry
> >> Sent: Friday, February 15, 2019 10:52 AM
> >>
> >> 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:
> >
> >
> > It looks okay to me and with the suggested device reference is being
> > released from every possible error leg in the function. Could you be
> > more specific which error path is not being addressed?
> >
> >> 	/* find the platform device corresponding to fwnode */
> >> 	if (is_of_node(dsaf_fwnode)) {
> >> 		pdev = of_find_device_by_node(to_of_node(dsaf_fwnode));
> >
> >
> > This will get the reference to the device, which needs to be
> > released later.
> >
> >
> >> 	} else if (is_acpi_device_node(dsaf_fwnode)) {
> >> 		pdev = hns_dsaf_find_platform_device(dsaf_fwnode);
> >
> >
> > This will also get the reference to the device when bus_find_device()
> > gets called and returns the 'device'. Therefore, this needs to be
> > released as well using put_device()
> 
> OK, I see. That's non-obvious.
> 
> And so the commit message was simply incomplete.
> 
> So who finally drops this reference? This patch only seems to release on
> error path. I checked the callers and they don't seem to.


Yes, in the positive leg the put_device() was missing. Thanks for identifying!
I have floated the patch to fix it https://www.lkml.org/lkml/2019/2/18/1161


Salil.


      reply	other threads:[~2019-02-18 17:54 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
2019-02-15 11:25   ` Salil Mehta
2019-02-15 12:00     ` John Garry
2019-02-18 17:54       ` Salil Mehta [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=961cf1cfaf05448092e517f4058ea062@huawei.com \
    --to=salil.mehta@huawei.com \
    --cc=davem@davemloft.net \
    --cc=huang.zijiang@zte.com.cn \
    --cc=john.garry@huawei.com \
    --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=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.