* [PATCH] iommufd/selftest: Use fdget() and fdput()
@ 2023-05-05 6:12 ye.xingchen
2023-05-05 11:55 ` Jason Gunthorpe
0 siblings, 1 reply; 2+ messages in thread
From: ye.xingchen @ 2023-05-05 6:12 UTC (permalink / raw)
To: jgg; +Cc: kevin.tian, joro, will, robin.murphy, iommu, linux-kernel
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);
- if (file->f_op != &iommfd_test_staccess_fops) {
- fput(file);
+ if (f.file->f_op != &iommfd_test_staccess_fops) {
+ fdput(f);
return ERR_PTR(-EBADFD);
}
- return file->private_data;
+ return f.file->private_data;
}
static void iommufd_test_access_unmap(void *data, unsigned long iova,
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iommufd/selftest: Use fdget() and fdput()
2023-05-05 6:12 [PATCH] iommufd/selftest: Use fdget() and fdput() ye.xingchen
@ 2023-05-05 11:55 ` Jason Gunthorpe
0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2023-05-05 11:55 UTC (permalink / raw)
To: ye.xingchen; +Cc: kevin.tian, joro, will, robin.murphy, iommu, linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-05 11:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-05 6:12 [PATCH] iommufd/selftest: Use fdget() and fdput() ye.xingchen
2023-05-05 11:55 ` Jason Gunthorpe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox