From: Jason Gunthorpe <jgg@ziepe.ca>
To: ye.xingchen@zte.com.cn
Cc: kevin.tian@intel.com, joro@8bytes.org, will@kernel.org,
robin.murphy@arm.com, iommu@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iommufd/selftest: Use fdget() and fdput()
Date: Fri, 5 May 2023 08:55:51 -0300 [thread overview]
Message-ID: <ZFTux7dKpV5zrQwc@ziepe.ca> (raw)
In-Reply-To: <202305051412396252364@zte.com.cn>
On Fri, May 05, 2023 at 02:12:39PM +0800, ye.xingchen@zte.com.cn wrote:
> From: Ye Xingchen <ye.xingchen@zte.com.cn>
>
> convert the fget()/fput() uses to fdget()/fdput().
>
> Signed-off-by: Ye Xingchen <ye.xingchen@zte.com.cn>
> ---
> drivers/iommu/iommufd/selftest.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c
> index 74c2076105d4..d3512fa673a5 100644
> --- a/drivers/iommu/iommufd/selftest.c
> +++ b/drivers/iommu/iommufd/selftest.c
> @@ -583,17 +583,16 @@ static const struct file_operations iommfd_test_staccess_fops;
>
> static struct selftest_access *iommufd_access_get(int fd)
> {
> - struct file *file;
> + struct fd f = fdget(fd);
>
> - file = fget(fd);
> - if (!file)
> + if (!f.file)
> return ERR_PTR(-EBADFD);
Why are you doing these conversions? This is wrong, fdget has to be
paired with fdput(), since the struct fd doesn't leave the stack frame
it cannot be correct.
I see your other patches have the same problem.
Jason
prev parent reply other threads:[~2023-05-05 11:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-05 6:12 [PATCH] iommufd/selftest: Use fdget() and fdput() ye.xingchen
2023-05-05 11:55 ` Jason Gunthorpe [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=ZFTux7dKpV5zrQwc@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
--cc=ye.xingchen@zte.com.cn \
/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