diff mbox series

[2/5] net: Use helper function fdput()

Message ID 1596714744-25247-1-git-send-email-linmiaohe@huawei.com
State New
Headers show
Series None | expand

Commit Message

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

Use helper function fdput() to fput() the file iff FDPUT_FPUT is set.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 net/socket.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/net/socket.c b/net/socket.c
index 976426d03f09..6aff5aeb6728 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1805,8 +1805,7 @@  int __sys_accept4(int fd, struct sockaddr __user *upeer_sockaddr,
 		ret = __sys_accept4_file(f.file, 0, upeer_sockaddr,
 						upeer_addrlen, flags,
 						rlimit(RLIMIT_NOFILE));
-		if (f.flags)
-			fput(f.file);
+		fdput(f);
 	}
 
 	return ret;
@@ -1869,8 +1868,7 @@  int __sys_connect(int fd, struct sockaddr __user *uservaddr, int addrlen)
 		ret = move_addr_to_kernel(uservaddr, addrlen, &address);
 		if (!ret)
 			ret = __sys_connect_file(f.file, &address, addrlen, 0);
-		if (f.flags)
-			fput(f.file);
+		fdput(f);
 	}
 
 	return ret;