Skip to content

Commit ae29750

Browse files
Dan CarpenterJ. Bruce Fields
authored andcommitted
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>
1 parent d435c05 commit ae29750

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

net/sunrpc/sysctl.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,20 @@ static int proc_do_xprt(struct ctl_table *table, int write,
6363
void *buffer, size_t *lenp, loff_t *ppos)
6464
{
6565
char tmpbuf[256];
66-
size_t len;
66+
ssize_t len;
6767

6868
if (write || *ppos) {
6969
*lenp = 0;
7070
return 0;
7171
}
7272
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);
7474

75-
if (*lenp < 0) {
75+
if (len < 0) {
7676
*lenp = 0;
7777
return -EINVAL;
7878
}
79+
*lenp = len;
7980
return 0;
8081
}
8182

0 commit comments

Comments
 (0)