Thread (5 messages) 5 messages, 5 authors, 2023-05-11

Re: [PATCH] vhost_net: Use fdget() and fdput()

From: Jason Wang <jasowang@redhat.com>
Date: 2023-05-05 06:46:34
Also in: kvm, lkml, virtualization

On Fri, May 5, 2023 at 2:24 PM [off-list ref] wrote:
From: Ye Xingchen <redacted>

convert the fget()/fput() uses to fdget()/fdput().
What's the advantages of this?

Thanks
quoted hunk ↗ jump to hunk
Signed-off-by: Ye Xingchen <redacted>
---
 drivers/vhost/net.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index ae2273196b0c..5b3fe4805182 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -1466,17 +1466,17 @@ static struct ptr_ring *get_tap_ptr_ring(struct file *file)

 static struct socket *get_tap_socket(int fd)
 {
-       struct file *file = fget(fd);
+       struct fd f = fdget(fd);
        struct socket *sock;

-       if (!file)
+       if (!f.file)
                return ERR_PTR(-EBADF);
-       sock = tun_get_socket(file);
+       sock = tun_get_socket(f.file);
        if (!IS_ERR(sock))
                return sock;
-       sock = tap_get_socket(file);
+       sock = tap_get_socket(f.file);
        if (IS_ERR(sock))
-               fput(file);
+               fdput(f);
        return sock;
 }

--
2.25.1
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help