Fixes: 9d71dd0 ("can: add support of SAE J1939 protocol") Signed-off-by: Devid Antonio Filoni <devid.filoni@xxxxxxxxxxxxxxxxxxxxx> --- net/can/j1939/transport.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c index 307ee1174a6e..030f5fe901e1 100644 --- a/net/can/j1939/transport.c +++ b/net/can/j1939/transport.c @@ -621,18 +621,30 @@ static int j1939_tp_tx_dat(struct j1939_session *session, const u8 *dat, int len) { struct j1939_priv *priv = session->priv; + struct sk_buff *se_skb; struct sk_buff *skb; + int ret; skb = j1939_tp_tx_dat_new(priv, &session->skcb, false, false); if (IS_ERR(skb)) return PTR_ERR(skb); + se_skb = j1939_session_skb_get(session); + if (se_skb) + can_skb_set_owner(skb, se_skb->sk); + skb_put_data(skb, dat, len); if (j1939_tp_padding && len < 8) memset(skb_put(skb, 8 - len), 0xff, 8 - len); - return j1939_send_one(priv, skb); + ret = j1939_send_one(priv, skb); + + if (ret) + kfree_skb(se_skb); + else + consume_skb(se_skb); + return ret; } static int j1939_xtp_do_tx_ctl(struct j1939_priv *priv, -- 2.25.1