SUNRPC: Fix error handling in svc_setup_socket()
authorChuck Lever <chuck.lever@oracle.com>
Thu, 4 May 2023 17:43:33 +0000 (13:43 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Sat, 6 May 2023 00:51:11 +0000 (20:51 -0400)
commit319050d4302ee9b216fb8cea847a9c4427628a98
tree82f8248a7712f4aac4e9974061e40285b18a3b65
parent29cd2927fb914cc53b5ba4f67d2b74695c994ba4
SUNRPC: Fix error handling in svc_setup_socket()

Dan points out that sock_alloc_file() releases @sock on error, but
so do all of svc_setup_socket's callers, resulting in a double-
release if sock_alloc_file() returns an error.

Rather than allocating a struct file for all new sockets, allocate
one only for sockets created during a TCP accept. For the moment,
those are the only ones that will ever be used with RPC-with-TLS.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Fixes: ae0d77708aae ("SUNRPC: Ensure server-side sockets have a sock->file")
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
net/sunrpc/svcsock.c