Skip to content

Commit

Permalink
can: j1939: transport: j1939_session_skb_drop_old(): spin_unlock_irqr…
Browse files Browse the repository at this point in the history
…estore() before kfree_skb()

It is not allowed to call kfree_skb() from hardware interrupt context
or with interrupts being disabled. The skb is unlinked from the queue,
so it can be freed after spin_unlock_irqrestore().

Fixes: 9d71dd0 ("can: add support of SAE J1939 protocol")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://lore.kernel.org/all/20221027091237.2290111-1-yangyingliang@huawei.com
Cc: stable@vger.kernel.org
[mkl: adjust subject]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Yang Yingliang authored and Marc Kleine-Budde committed Oct 27, 2022
1 parent fd0c3b7 commit c3c06c6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/can/j1939/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,12 @@ static void j1939_session_skb_drop_old(struct j1939_session *session)
__skb_unlink(do_skb, &session->skb_queue);
/* drop ref taken in j1939_session_skb_queue() */
skb_unref(do_skb);
spin_unlock_irqrestore(&session->skb_queue.lock, flags);

kfree_skb(do_skb);
} else {
spin_unlock_irqrestore(&session->skb_queue.lock, flags);
}
spin_unlock_irqrestore(&session->skb_queue.lock, flags);
}

void j1939_session_skb_queue(struct j1939_session *session,
Expand Down

0 comments on commit c3c06c6

Please sign in to comment.