Skip to content

Commit 5c40486

Browse files
Hextagregkh
authored andcommitted
net/sunrpc: Fix return value for sysctl sunrpc.transports
commit c09f56b upstream. Fix returning value for sysctl sunrpc.transports. Return error code from sysctl proc_handler function proc_do_xprt instead of number of the written bytes. Otherwise sysctl returns random garbage for this key. Since v1: - Handle negative returned value from memory_read_from_buffer as an error Signed-off-by: Artur Molchanov <arturmolchanov@gmail.com> Cc: stable@vger.kernel.org Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 29a41f7 commit 5c40486

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

net/sunrpc/sysctl.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,13 @@ static int proc_do_xprt(struct ctl_table *table, int write,
7070
return 0;
7171
}
7272
len = svc_print_xprts(tmpbuf, sizeof(tmpbuf));
73-
return memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len);
73+
*lenp = memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len);
74+
75+
if (*lenp < 0) {
76+
*lenp = 0;
77+
return -EINVAL;
78+
}
79+
return 0;
7480
}
7581

7682
static int

0 commit comments

Comments
 (0)