From: Xu Yilun <yilun.xu@linux.intel.com>
To: Marco Pagani <marpagan@redhat.com>
Cc: Jinjie Ruan <ruanjinjie@huawei.com>,
Moritz Fischer <mdf@kernel.org>, Xu Yilun <yilun.xu@intel.com>,
Tom Rix <trix@redhat.com>, Wu Hao <hao.wu@intel.com>,
linux-fpga@vger.kernel.org
Subject: Re: [PATCH] fpga: Fix memory leak for fpga_region_test_class_find()
Date: Thu, 12 Oct 2023 13:05:34 +0800 [thread overview]
Message-ID: <ZSd+npcx0KZuYUjP@yilunxu-OptiPlex-7050> (raw)
In-Reply-To: <d14b4c86-8d6b-a9b3-c81a-34f07301cf96@redhat.com>
On Mon, Oct 09, 2023 at 02:03:18PM +0200, Marco Pagani wrote:
>
>
> On 2023-10-07 11:43, Jinjie Ruan wrote:
> > When CONFIG_FPGA_KUNIT_TESTS=m and making CONFIG_DEBUG_KMEMLEAK=y
> > and CONFIG_DEBUG_KMEMLEAK_AUTO_SCAN=y, modprobe fpga-region-test and then
> > rmmod fpga-region-test, the below memory leak is detected.
> >
> > fpga_region_class_find() in fpga_region_test_class_find() will call
> > get_device() if the data is matched, which will increment refcount for
> > dev->kobj, so it should call put_device() to decrement refcount for
> > dev->kobj to free the region, because fpga_region_unregister() will call
> > fpga_region_dev_release() only when the refcount for dev->kobj is zero
> > but fpga_region_test_init() call device_register() in
> > fpga_region_register_full(), which also increment refcount.
> >
> > So call put_device() after calling fpga_region_class_find() in
> > fpga_region_test_class_find(). After applying this patch, the following
>
> Looks good to me. Thanks.
>
> Reviewed-by: Marco Pagani <marpagan@redhat.com>
Acked-by: Xu Yilun <yilun.xu@intel.com>
Applied.
prev parent reply other threads:[~2023-10-12 5:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-07 9:43 [PATCH] fpga: Fix memory leak for fpga_region_test_class_find() Jinjie Ruan
2023-10-09 12:03 ` Marco Pagani
2023-10-12 5:05 ` Xu Yilun [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=ZSd+npcx0KZuYUjP@yilunxu-OptiPlex-7050 \
--to=yilun.xu@linux.intel.com \
--cc=hao.wu@intel.com \
--cc=linux-fpga@vger.kernel.org \
--cc=marpagan@redhat.com \
--cc=mdf@kernel.org \
--cc=ruanjinjie@huawei.com \
--cc=trix@redhat.com \
--cc=yilun.xu@intel.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 read-only IMAP folder(s) and NNTP newsgroup(s).