Skip to content

Commit

Permalink
socket: Tighten no-error check in bind()
Browse files Browse the repository at this point in the history
move_addr_to_kernel() returns only negative values on error, or zero on
success. Rewrite the error check to an idiomatic form to avoid confusing
the reader.

Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jakub Sitnicki authored and David S. Miller committed Oct 5, 2018
1 parent 9a694c1 commit 068b88c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,7 @@ int __sys_bind(int fd, struct sockaddr __user *umyaddr, int addrlen)
sock = sockfd_lookup_light(fd, &err, &fput_needed);
if (sock) {
err = move_addr_to_kernel(umyaddr, addrlen, &address);
if (err >= 0) {
if (!err) {
err = security_socket_bind(sock,
(struct sockaddr *)&address,
addrlen);
Expand Down

0 comments on commit 068b88c

Please sign in to comment.