Re: [PATCH] vfio: Use filp instead of fd

Al Viro
2022-09-27T01:37:35Z

On Tue, Sep 27, 2022 at 01:21:50AM +0000, tomorrow Wang (王德明) wrote:
> Hi
>
> Why kvm_vfio_group_add use file.
>
> struct file *filp;
> .....
> filp = fget(fd);
>
> .....
> kvg->file = filp;

This is why. Note that you've slightly misquoted it - it's actually
either "stick into kvg->file" or "fput() it".

> ......
> fput(filp);

The reference we are getting here is non-transient one; it will be retained
in shared data structures after we return from function - hell, after we
return to userland.