* [PATCH v2] can: j1939: transport: replace kfree_skb() with dev_kfree_skb_irq()
@ 2022-10-27 9:12 Yang Yingliang
2022-10-27 11:29 ` Oleksij Rempel
0 siblings, 1 reply; 2+ messages in thread
From: Yang Yingliang @ 2022-10-27 9:12 UTC (permalink / raw)
To: linux-can, netdev; +Cc: robin, linux, kernel, socketcan, mkl
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: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
v1 -> v2:
Move kfree_skb() after spin_unlock_irqrestore().
---
net/can/j1939/transport.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
index d7d86c944d76..55f29c9f9e08 100644
--- a/net/can/j1939/transport.c
+++ b/net/can/j1939/transport.c
@@ -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,
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] can: j1939: transport: replace kfree_skb() with dev_kfree_skb_irq()
2022-10-27 9:12 [PATCH v2] can: j1939: transport: replace kfree_skb() with dev_kfree_skb_irq() Yang Yingliang
@ 2022-10-27 11:29 ` Oleksij Rempel
0 siblings, 0 replies; 2+ messages in thread
From: Oleksij Rempel @ 2022-10-27 11:29 UTC (permalink / raw)
To: Yang Yingliang; +Cc: linux-can, netdev, robin, linux, kernel, socketcan, mkl
On Thu, Oct 27, 2022 at 05:12:37PM +0800, Yang Yingliang wrote:
> 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: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
> v1 -> v2:
> Move kfree_skb() after spin_unlock_irqrestore().
> ---
> net/can/j1939/transport.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
> index d7d86c944d76..55f29c9f9e08 100644
> --- a/net/can/j1939/transport.c
> +++ b/net/can/j1939/transport.c
> @@ -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,
> --
> 2.25.1
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-27 11:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-27 9:12 [PATCH v2] can: j1939: transport: replace kfree_skb() with dev_kfree_skb_irq() Yang Yingliang
2022-10-27 11:29 ` Oleksij Rempel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.