Skip to content

Commit

Permalink
net/sunrpc: Fix return value for sysctl sunrpc.transports
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Hexta authored and gregkh committed Nov 5, 2020
1 parent 29a41f7 commit 5c40486
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion net/sunrpc/sysctl.c
Expand Up @@ -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
Expand Down

0 comments on commit 5c40486

Please sign in to comment.