Skip to content

Commit

Permalink
net: Use helper function fdput()
Browse files Browse the repository at this point in the history
Use helper function fdput() to fput() the file iff FDPUT_FPUT is set.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Miaohe Lin authored and David S. Miller committed Aug 8, 2020
1 parent d02cbc4 commit 6b07ede
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1804,8 +1804,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;
Expand Down Expand Up @@ -1868,8 +1867,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;
Expand Down

0 comments on commit 6b07ede

Please sign in to comment.