diff mbox series

[3/5] net: Set fput_needed iff FDPUT_FPUT is set

Message ID 1596714796-25298-1-git-send-email-linmiaohe@huawei.com
State Accepted
Delegated to: David Miller
Headers show
Series None | expand

Commit Message

Miaohe Lin Aug. 6, 2020, 11:53 a.m. UTC
From: Miaohe Lin <linmiaohe@huawei.com>

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>
---
 net/socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Miller Aug. 8, 2020, 9:22 p.m. UTC | #1
From: linmiaohe <linmiaohe@huawei.com>
Date: Thu, 6 Aug 2020 19:53:16 +0800

> From: Miaohe Lin <linmiaohe@huawei.com>
> 
> 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>

Applied.
diff mbox series

Patch

diff --git a/net/socket.c b/net/socket.c
index 6aff5aeb6728..ee9c9dac4728 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -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);