In some cases new session can be aborted before we got an loopback rts. In this rare case we will create invalid session. To avoid it, don't create a session if we are transmitter. Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx> --- net/can/j1939/transport.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c index cb4e8be7de0a..3e0345122a0c 100644 --- a/net/can/j1939/transport.c +++ b/net/can/j1939/transport.c @@ -1510,6 +1510,20 @@ static void j1939_xtp_rx_rts(struct j1939_priv *priv, struct sk_buff *skb, j1939_session_put(session); return; } + } else if (transmitter) { + /* If we're the transmitter and this function is called, we + * received our own RTS. A session has already been created. + * + * For some reasons however it might have been destroyed + * already. So don't create a new one here (using + * "j1939_xtp_rx_rts_session_new()") as this will be a receiver + * session. + * + * The reasons the session is already destroyed might be: + * - user space closed socket was and the session was aborted + * - session was aborted due to external abort message + */ + return; } else { session = j1939_xtp_rx_rts_session_new(priv, skb); if (!session) -- 2.20.1