Skip to content

Commit aad41a7

Browse files
author
Trond Myklebust
committed
SUNRPC: Don't leak sockets in xs_local_connect()
If there is still a closed socket associated with the transport, then we need to trigger an autoclose before we can set up a new connection. Reported-by: wanghai (M) <wanghai38@huawei.com> Fixes: f004320 ("SUNRPC: Ensure we flush any closed sockets before xs_xprt_free()") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent 00c94eb commit aad41a7

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

net/sunrpc/xprtsock.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1950,6 +1950,9 @@ static void xs_local_connect(struct rpc_xprt *xprt, struct rpc_task *task)
19501950
struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
19511951
int ret;
19521952

1953+
if (transport->file)
1954+
goto force_disconnect;
1955+
19531956
if (RPC_IS_ASYNC(task)) {
19541957
/*
19551958
* We want the AF_LOCAL connect to be resolved in the
@@ -1962,11 +1965,17 @@ static void xs_local_connect(struct rpc_xprt *xprt, struct rpc_task *task)
19621965
*/
19631966
task->tk_rpc_status = -ENOTCONN;
19641967
rpc_exit(task, -ENOTCONN);
1965-
return;
1968+
goto out_wake;
19661969
}
19671970
ret = xs_local_setup_socket(transport);
19681971
if (ret && !RPC_IS_SOFTCONN(task))
19691972
msleep_interruptible(15000);
1973+
return;
1974+
force_disconnect:
1975+
xprt_force_disconnect(xprt);
1976+
out_wake:
1977+
xprt_clear_connecting(xprt);
1978+
xprt_wake_pending_tasks(xprt, -ENOTCONN);
19701979
}
19711980

19721981
#if IS_ENABLED(CONFIG_SUNRPC_SWAP)

0 commit comments

Comments
 (0)