Skip to contentSkip to conversation

socket: Tighten no-error check in bind()

PATCH Applied Jakub Sitnicki 2 participants 2 messages Oct 4, 2018 – Oct 6, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 socket: Tighten no-error check in bind()

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.

---
 net/socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/socket.c +1 -1
index 01f3f8f32d6f..713dc4833d40 100644
@@ -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);
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw

From: Jakub Sitnicki <[email protected]>
Date: Thu, 4 Oct 2018 11:09:40 +0200

Quoted 5 lines

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.

Applied.