summaryrefslogtreecommitdiffstats
path: root/net/can/j1939
diff options
context:
space:
mode:
authorOleksij Rempel <o.rempel@pengutronix.de>2019-11-07 18:51:40 +0100
committerMarc Kleine-Budde <mkl@pengutronix.de>2019-11-13 10:42:34 +0100
commit62ebce1dc1fa649a1c54db02f1a3c409bb0529ec (patch)
treeaff58be68e2a401a47eae4a1562c529fe8174430 /net/can/j1939
parentd966635b384b9571a43bd38c61f280c47eb564ad (diff)
downloadlinux-62ebce1dc1fa649a1c54db02f1a3c409bb0529ec.tar.bz2
can: j1939: make sure socket is held as long as session exists
We link the socket to the session to be able provide socket specific notifications. For example messages over error queue. We need to keep the socket held, while we have a reference to it. Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol") Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Diffstat (limited to 'net/can/j1939')
-rw-r--r--net/can/j1939/transport.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
index ecdedfc0b10c..afc2adfd97e4 100644
--- a/net/can/j1939/transport.c
+++ b/net/can/j1939/transport.c
@@ -255,6 +255,7 @@ static void __j1939_session_drop(struct j1939_session *session)
return;
j1939_sock_pending_del(session->sk);
+ sock_put(session->sk);
}
static void j1939_session_destroy(struct j1939_session *session)
@@ -1875,6 +1876,7 @@ struct j1939_session *j1939_tp_send(struct j1939_priv *priv,
return ERR_PTR(-ENOMEM);
/* skb is recounted in j1939_session_new() */
+ sock_hold(skb->sk);
session->sk = skb->sk;
session->transmission = true;
session->pkt.total = (size + 6) / 7;