]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Aug 2020 08:53:03 +0000 (10:53 +0200)
[ Upstream commit ce787a5a074a86f76f5d3fd804fa78e01bfb9e89 ]

We should fput() file iff FDPUT_FPUT is set. So we should set fput_needed
accordingly.

Fixes: 00e188ef6a7e ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/socket.c

index 88086d18c20860770ab65bb823bca681f2fba0fe..1392461d391ad5c5002c61fb4f9afa80cf394557 100644 (file)
@@ -456,7 +456,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);