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

net: streamline __sys_setsockopt

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 a06d30ae
...@@ -2107,18 +2107,18 @@ static int __sys_setsockopt(int fd, int level, int optname, ...@@ -2107,18 +2107,18 @@ static int __sys_setsockopt(int fd, int level, int optname,
return -EINVAL; return -EINVAL;
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_setsockopt(sock, level, optname); err = security_socket_setsockopt(sock, level, optname);
if (err) if (err)
goto out_put; goto out_put;
err = BPF_CGROUP_RUN_PROG_SETSOCKOPT(sock->sk, &level, err = BPF_CGROUP_RUN_PROG_SETSOCKOPT(sock->sk, &level, &optname,
&optname, optval, &optlen, optval, &optlen, &kernel_optval);
&kernel_optval); if (err < 0)
if (err < 0) {
goto out_put; goto out_put;
} else if (err > 0) { if (err > 0) {
err = 0; err = 0;
goto out_put; goto out_put;
} }
...@@ -2129,21 +2129,18 @@ static int __sys_setsockopt(int fd, int level, int optname, ...@@ -2129,21 +2129,18 @@ static int __sys_setsockopt(int fd, int level, int optname,
} }
if (level == SOL_SOCKET && !sock_use_custom_sol_socket(sock)) if (level == SOL_SOCKET && !sock_use_custom_sol_socket(sock))
err = err = sock_setsockopt(sock, level, optname, optval, optlen);
sock_setsockopt(sock, level, optname, optval,
optlen);
else else
err = err = sock->ops->setsockopt(sock, level, optname, optval,
sock->ops->setsockopt(sock, level, optname, optval,
optlen); optlen);
if (kernel_optval) { if (kernel_optval) {
set_fs(oldfs); set_fs(oldfs);
kfree(kernel_optval); kfree(kernel_optval);
} }
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