summaryrefslogtreecommitdiff
path: root/net/sunrpc/sysctl.c
diff options
context:
space:
mode:
authorArtur Molchanov <arturmolchanov@gmail.com>2020-10-12 01:00:45 +0300
committerJ. Bruce Fields <bfields@redhat.com>2020-10-16 15:15:04 -0400
commitc09f56b8f68d4d536bff518227aea323b835b2ce (patch)
treeb05a98a9aa0ce5677adaccaff73eeee9dd7b8960 /net/sunrpc/sysctl.c
parent9f0b5792f07d8f0745c3620d577d6930ff2a96fd (diff)
downloadlwn-c09f56b8f68d4d536bff518227aea323b835b2ce.tar.gz
lwn-c09f56b8f68d4d536bff518227aea323b835b2ce.zip
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 <arturmolchanov@gmail.com> Cc: stable@vger.kernel.org Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'net/sunrpc/sysctl.c')
-rw-r--r--net/sunrpc/sysctl.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c
index 999eee1ed61c..e81a28f30f1d 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