Skip to contentSkip to conversation

net/sunrpc: fix unsigned size_t comparison to less than zero

PATCH New Colin King 1 participant 1 message Oct 28, 2020

Subsystems (5)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 net/sunrpc: fix unsigned size_t comparison to less than zero

From: Colin Ian King <[email protected]>

Currently the check for *lenp < 0 is always true since the type is a size_t and can never be negative. Fix this by casting it to ssize_t.

Addresses-Coverity: ("Unsigned compared against 0")

Fixes c09f56b8f68d ("net/sunrpc: Fix return value for sysctl sunrpc.transports")
---
 net/sunrpc/sysctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sunrpc/sysctl.c +1 -1
index a18b36b5422d..bb62badef6bc 100644
@@ -72,7 +72,7 @@ static int proc_do_xprt(struct ctl_table *table, int write,
 	len = svc_print_xprts(tmpbuf, sizeof(tmpbuf));
 	*lenp = memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len);
 
-	if (*lenp < 0) {
+	if ((ssize_t)*lenp < 0) {
 		*lenp = 0;
 		return -EINVAL;
 	}
Signature · 1 line
2.27.0