From: Dan Carpenter Date: Fri, 6 Nov 2020 20:50:39 +0000 (-0500) Subject: net/sunrpc: fix useless comparison in proc_do_xprt() X-Git-Tag: v5.15~2399^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ae2975046dbc65855c217fe6fbd5b33140c5ff18;p=platform%2Fkernel%2Flinux-starfive.git net/sunrpc: fix useless comparison in proc_do_xprt() In the original code, the "if (*lenp < 0)" check didn't work because "*lenp" is unsigned. Fortunately, the memory_read_from_buffer() call will never fail in this context so it doesn't affect runtime. Signed-off-by: Dan Carpenter Signed-off-by: J. Bruce Fields --- diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c index 5c9f5bc..3aad6ef 100644 --- a/net/sunrpc/sysctl.c +++ b/net/sunrpc/sysctl.c @@ -63,19 +63,20 @@ static int proc_do_xprt(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { char tmpbuf[256]; - size_t len; + ssize_t len; if (write || *ppos) { *lenp = 0; return 0; } len = svc_print_xprts(tmpbuf, sizeof(tmpbuf)); - *lenp = memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len); + len = memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len); - if (*lenp < 0) { + if (len < 0) { *lenp = 0; return -EINVAL; } + *lenp = len; return 0; }