Commit d8a9b38f authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David S. Miller

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: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4a367299
...@@ -2163,7 +2163,9 @@ static int __sys_getsockopt(int fd, int level, int optname, ...@@ -2163,7 +2163,9 @@ 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)
return err;
err = security_socket_getsockopt(sock, level, optname); err = security_socket_getsockopt(sock, level, optname);
if (err) if (err)
goto out_put; goto out_put;
...@@ -2171,20 +2173,15 @@ static int __sys_getsockopt(int fd, int level, int optname, ...@@ -2171,20 +2173,15 @@ static int __sys_getsockopt(int fd, int level, int optname,
max_optlen = BPF_CGROUP_GETSOCKOPT_MAX_OPTLEN(optlen); max_optlen = BPF_CGROUP_GETSOCKOPT_MAX_OPTLEN(optlen);
if (level == SOL_SOCKET) if (level == SOL_SOCKET)
err = err = sock_getsockopt(sock, level, optname, optval, optlen);
sock_getsockopt(sock, level, optname, optval,
optlen);
else else
err = err = sock->ops->getsockopt(sock, level, optname, optval,
sock->ops->getsockopt(sock, level, optname, optval,
optlen); 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;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment