From: Artur Molchanov Date: Sun, 11 Oct 2020 22:00:45 +0000 (+0300) Subject: net/sunrpc: Fix return value for sysctl sunrpc.transports X-Git-Tag: v5.10.7~1355^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c09f56b8f68d4d536bff518227aea323b835b2ce;p=platform%2Fkernel%2Flinux-rpi.git net/sunrpc: Fix return value for sysctl sunrpc.transports 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 Cc: stable@vger.kernel.org Signed-off-by: J. Bruce Fields --- diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c index 999eee1..e81a28f 100644 --- a/net/sunrpc/sysctl.c +++ b/net/sunrpc/sysctl.c @@ -70,7 +70,13 @@ static int proc_do_xprt(struct ctl_table *table, int write, return 0; } len = svc_print_xprts(tmpbuf, sizeof(tmpbuf)); - return memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len); + *lenp = memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len); + + if (*lenp < 0) { + *lenp = 0; + return -EINVAL; + } + return 0; } static int