]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: Set fput_needed iff FDPUT_FPUT is set
authorMiaohe Lin <linmiaohe@huawei.com>
Thu, 6 Aug 2020 11:53:16 +0000 (19:53 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 8 Aug 2020 21:21:42 +0000 (14:21 -0700)
We should fput() file iff FDPUT_FPUT is set. So we should set fput_needed
accordingly.

Fixes: 03400a8b3187 ("sockfd_lookup_light(): switch to fdget^W^Waway from fget_light")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/socket.c

index 3c3d6abe4c1eef5f32073e8034aff54d360a223e..e08415b4f9397976af2c5c8fe6a4b3ca7a53ba44 100644 (file)
@@ -500,7 +500,7 @@ static struct socket *sockfd_lookup_light(int fd, int *err, int *fput_needed)
        if (f.file) {
                sock = sock_from_file(f.file, err);
                if (likely(sock)) {
-                       *fput_needed = f.flags;
+                       *fput_needed = f.flags & FDPUT_FPUT;
                        return sock;
                }
                fdput(f);