mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-26 05:34:13 +08:00
net: streamline __sys_getsockopt
Return early when sockfd_lookup_light fails to reduce a level of indentation for most of the function body. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
4a3672993f
commit
d8a9b38f83
31
net/socket.c
31
net/socket.c
@ -2163,28 +2163,25 @@ static int __sys_getsockopt(int fd, int level, int optname,
|
|||||||
int max_optlen;
|
int max_optlen;
|
||||||
|
|
||||||
sock = sockfd_lookup_light(fd, &err, &fput_needed);
|
sock = sockfd_lookup_light(fd, &err, &fput_needed);
|
||||||
if (sock != NULL) {
|
if (!sock)
|
||||||
err = security_socket_getsockopt(sock, level, optname);
|
return err;
|
||||||
if (err)
|
|
||||||
goto out_put;
|
|
||||||
|
|
||||||
max_optlen = BPF_CGROUP_GETSOCKOPT_MAX_OPTLEN(optlen);
|
err = security_socket_getsockopt(sock, level, optname);
|
||||||
|
if (err)
|
||||||
|
goto out_put;
|
||||||
|
|
||||||
if (level == SOL_SOCKET)
|
max_optlen = BPF_CGROUP_GETSOCKOPT_MAX_OPTLEN(optlen);
|
||||||
err =
|
|
||||||
sock_getsockopt(sock, level, optname, optval,
|
if (level == SOL_SOCKET)
|
||||||
|
err = sock_getsockopt(sock, level, optname, optval, optlen);
|
||||||
|
else
|
||||||
|
err = sock->ops->getsockopt(sock, level, optname, optval,
|
||||||
optlen);
|
optlen);
|
||||||
else
|
|
||||||
err =
|
|
||||||
sock->ops->getsockopt(sock, level, optname, optval,
|
|
||||||
optlen);
|
|
||||||
|
|
||||||
err = BPF_CGROUP_RUN_PROG_GETSOCKOPT(sock->sk, level, optname,
|
err = BPF_CGROUP_RUN_PROG_GETSOCKOPT(sock->sk, level, optname, optval,
|
||||||
optval, optlen,
|
optlen, max_optlen, err);
|
||||||
max_optlen, err);
|
|
||||||
out_put:
|
out_put:
|
||||||
fput_light(sock->file, fput_needed);
|
fput_light(sock->file, fput_needed);
|
||||||
}
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user