Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <dan.carpenter@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>

authored by

Dan Carpenter and committed by
J. Bruce Fields
ae297504 d435c05a

+4 -3
+4 -3
net/sunrpc/sysctl.c
··· 63 63 void *buffer, size_t *lenp, loff_t *ppos) 64 64 { 65 65 char tmpbuf[256]; 66 - size_t len; 66 + ssize_t len; 67 67 68 68 if (write || *ppos) { 69 69 *lenp = 0; 70 70 return 0; 71 71 } 72 72 len = svc_print_xprts(tmpbuf, sizeof(tmpbuf)); 73 - *lenp = memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len); 73 + len = memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len); 74 74 75 - if (*lenp < 0) { 75 + if (len < 0) { 76 76 *lenp = 0; 77 77 return -EINVAL; 78 78 } 79 + *lenp = len; 79 80 return 0; 80 81 } 81 82