]> git.baikalelectronics.ru Git - kernel.git/commitdiff
socket: Tighten no-error check in bind()
authorJakub Sitnicki <jakub@cloudflare.com>
Thu, 4 Oct 2018 09:09:40 +0000 (11:09 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 5 Oct 2018 21:34:45 +0000 (14:34 -0700)
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>
net/socket.c

index 01f3f8f32d6f927fd77bac5920ab5d8339c2f6af..713dc4833d40c729ff422e70ffde5ddee626c3bd 100644 (file)
@@ -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);