diff mbox series

can: j1939: transport: replace kfree_skb() with dev_kfree_skb_irq()

Message ID 20221026125354.911575-1-yangyingliang@huawei.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series can: j1939: transport: replace kfree_skb() with dev_kfree_skb_irq() | expand

Checks

Context Check Description
netdev/tree_selection success Series ignored based on subject

Commit Message

Yang Yingliang Oct. 26, 2022, 12:53 p.m. UTC
It is not allowed to call kfree_skb() from hardware interrupt
context or with interrupts being disabled. So replace kfree_skb()
with dev_kfree_skb_irq() under spin_lock_irqsave().

Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 net/can/j1939/transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Marc Kleine-Budde Oct. 27, 2022, 8:06 a.m. UTC | #1
On 26.10.2022 20:53:54, Yang Yingliang wrote:
> It is not allowed to call kfree_skb() from hardware interrupt
> context or with interrupts being disabled. So replace kfree_skb()
> with dev_kfree_skb_irq() under spin_lock_irqsave().
> 
> Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  net/can/j1939/transport.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
> index d7d86c944d76..b95fb759c49d 100644
> --- a/net/can/j1939/transport.c
> +++ b/net/can/j1939/transport.c
> @@ -343,7 +343,7 @@ static void j1939_session_skb_drop_old(struct j1939_session *session)
>  		/* drop ref taken in j1939_session_skb_queue() */
>  		skb_unref(do_skb);
>  
> -		kfree_skb(do_skb);
> +		dev_kfree_skb_irq(do_skb);

Can you call spin_unlock_irqrestore() before the kfree_skb()? Does that
fix the problem?

>  	}
>  	spin_unlock_irqrestore(&session->skb_queue.lock, flags);
>  }

Marc
diff mbox series

Patch

diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
index d7d86c944d76..b95fb759c49d 100644
--- a/net/can/j1939/transport.c
+++ b/net/can/j1939/transport.c
@@ -343,7 +343,7 @@  static void j1939_session_skb_drop_old(struct j1939_session *session)
 		/* drop ref taken in j1939_session_skb_queue() */
 		skb_unref(do_skb);
 
-		kfree_skb(do_skb);
+		dev_kfree_skb_irq(do_skb);
 	}
 	spin_unlock_irqrestore(&session->skb_queue.lock, flags);
 }