Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Yi Liu <yi.l.liu@intel.com>
To: Nicolin Chen <nicolinc@nvidia.com>, <jgg@nvidia.com>,
	<kevin.tian@intel.com>
Cc: <baolu.lu@linux.intel.com>, <iommu@lists.linux.dev>,
	<linux-kernel@vger.kernel.org>, <linux-kselftest@vger.kernel.org>,
	<shuah@kernel.org>
Subject: Re: [PATCH v1 1/2] iommufd/fault: Fix out_fput in iommufd_fault_alloc()
Date: Tue, 3 Dec 2024 17:52:42 +0800	[thread overview]
Message-ID: <a6487e28-787a-4c9a-9dcb-15d92d0f6b3d@intel.com> (raw)
In-Reply-To: <b5651beb3a6b1adeef26fffac24607353bf67ba1.1733212723.git.nicolinc@nvidia.com>

On 2024/12/3 16:02, Nicolin Chen wrote:
> As fput() calls the file->f_op->release op, where fault obj and ictx are
> getting released, there is no need to release these two after fput() one
> more time, which would result in imbalanced refcounts:
>    refcount_t: decrement hit 0; leaking memory.
>    WARNING: CPU: 48 PID: 2369 at lib/refcount.c:31 refcount_warn_saturate+0x60/0x230
>    Call trace:
>     refcount_warn_saturate+0x60/0x230 (P)
>     refcount_warn_saturate+0x60/0x230 (L)
>     iommufd_fault_fops_release+0x9c/0xe0 [iommufd]
>    ...
>    VFS: Close: file count is 0 (f_op=iommufd_fops [iommufd])
>    WARNING: CPU: 48 PID: 2369 at fs/open.c:1507 filp_flush+0x3c/0xf0
>    Call trace:
>     filp_flush+0x3c/0xf0 (P)
>     filp_flush+0x3c/0xf0 (L)
>     __arm64_sys_close+0x34/0x98
>    ...
>    imbalanced put on file reference count
>    WARNING: CPU: 48 PID: 2369 at fs/file.c:74 __file_ref_put+0x100/0x138
>    Call trace:
>     __file_ref_put+0x100/0x138 (P)
>     __file_ref_put+0x100/0x138 (L)
>     __fput_sync+0x4c/0xd0
> 
> Drop those two lines to fix the warnings above.
> 
> Fixes: 07838f7fd529 ("iommufd: Add iommufd fault object")
> Cc: stable@vger.kernel.org
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> ---
>   drivers/iommu/iommufd/fault.c | 2 --
>   1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/iommu/iommufd/fault.c b/drivers/iommu/iommufd/fault.c
> index 053b0e30f55a..1fe804e28a86 100644
> --- a/drivers/iommu/iommufd/fault.c
> +++ b/drivers/iommu/iommufd/fault.c
> @@ -420,8 +420,6 @@ int iommufd_fault_alloc(struct iommufd_ucmd *ucmd)
>   	put_unused_fd(fdno);
>   out_fput:
>   	fput(filep);
> -	refcount_dec(&fault->obj.users);
> -	iommufd_ctx_put(fault->ictx);
>   out_abort:
>   	iommufd_object_abort_and_destroy(ucmd->ictx, &fault->obj);
>   

Reviewed-by: Yi Liu <yi.l.liu@intel.com>

-- 
Regards,
Yi Liu

  reply	other threads:[~2024-12-03  9:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-03  8:02 [PATCH v1 0/2] iommufd: Fix a small bug in fault.c Nicolin Chen
2024-12-03  8:02 ` [PATCH v1 1/2] iommufd/fault: Fix out_fput in iommufd_fault_alloc() Nicolin Chen
2024-12-03  9:52   ` Yi Liu [this message]
2024-12-03  8:02 ` [PATCH v1 2/2] iommufd/selftest: Cover IOMMU_FAULT_QUEUE_ALLOC in iommufd_fail_nth Nicolin Chen
2024-12-03 16:23 ` [PATCH v1 0/2] iommufd: Fix a small bug in fault.c Jason Gunthorpe

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=a6487e28-787a-4c9a-9dcb-15d92d0f6b3d@intel.com \
    --to=yi.l.liu@intel.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=nicolinc@nvidia.com \
    --cc=shuah@kernel.org \
    /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