Skip to content

Commit 53a3f77

Browse files
BernardMetzlerrleon
authored andcommitted
RDMA/siw: Fix connection failure handling
In case immediate MPA request processing fails, the newly created endpoint unlinks the listening endpoint and is ready to be dropped. This special case was not handled correctly by the code handling the later TCP socket close, causing a NULL dereference crash in siw_cm_work_handler() when dereferencing a NULL listener. We now also cancel the useless MPA timeout, if immediate MPA request processing fails. This patch furthermore simplifies MPA processing in general: Scheduling a useless TCP socket read in sk_data_ready() upcall is now surpressed, if the socket is already moved out of TCP_ESTABLISHED state. Fixes: 6c52fdc ("rdma/siw: connection management") Signed-off-by: Bernard Metzler <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent e193b79 commit 53a3f77

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

drivers/infiniband/sw/siw/siw_cm.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,7 @@ static void siw_accept_newconn(struct siw_cep *cep)
976976
siw_cep_put(cep);
977977
new_cep->listen_cep = NULL;
978978
if (rv) {
979+
siw_cancel_mpatimer(new_cep);
979980
siw_cep_set_free(new_cep);
980981
goto error;
981982
}
@@ -1100,9 +1101,12 @@ static void siw_cm_work_handler(struct work_struct *w)
11001101
/*
11011102
* Socket close before MPA request received.
11021103
*/
1103-
siw_dbg_cep(cep, "no mpareq: drop listener\n");
1104-
siw_cep_put(cep->listen_cep);
1105-
cep->listen_cep = NULL;
1104+
if (cep->listen_cep) {
1105+
siw_dbg_cep(cep,
1106+
"no mpareq: drop listener\n");
1107+
siw_cep_put(cep->listen_cep);
1108+
cep->listen_cep = NULL;
1109+
}
11061110
}
11071111
}
11081112
release_cep = 1;
@@ -1227,7 +1231,11 @@ static void siw_cm_llp_data_ready(struct sock *sk)
12271231
if (!cep)
12281232
goto out;
12291233

1230-
siw_dbg_cep(cep, "state: %d\n", cep->state);
1234+
siw_dbg_cep(cep, "cep state: %d, socket state %d\n",
1235+
cep->state, sk->sk_state);
1236+
1237+
if (sk->sk_state != TCP_ESTABLISHED)
1238+
goto out;
12311239

12321240
switch (cep->state) {
12331241
case SIW_EPSTATE_RDMA_MODE:

0 commit comments

Comments
 (0)