Commit e9ad4986 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'misdn-don-t-call-dev_kfree_skb-kfree_skb-under-spin_lock_irqsave'

Yang Yingliang says:

====================
mISDN: don't call dev_kfree_skb/kfree_skb() under spin_lock_irqsave()

It is not allowed to call kfree_skb() or consume_skb() from hardware
interrupt context or with hardware interrupts being disabled. This
pachset try to avoid calling dev_kfree_skb/kfree_skb()() under
spin_lock_irqsave().
====================

Link: https://lore.kernel.org/r/20221212084139.3277913-1-yangyingliang@huawei.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents da2b5b43 1232946c
...@@ -3217,6 +3217,7 @@ static int ...@@ -3217,6 +3217,7 @@ static int
hfcm_l1callback(struct dchannel *dch, u_int cmd) hfcm_l1callback(struct dchannel *dch, u_int cmd)
{ {
struct hfc_multi *hc = dch->hw; struct hfc_multi *hc = dch->hw;
struct sk_buff_head free_queue;
u_long flags; u_long flags;
switch (cmd) { switch (cmd) {
...@@ -3245,6 +3246,7 @@ hfcm_l1callback(struct dchannel *dch, u_int cmd) ...@@ -3245,6 +3246,7 @@ hfcm_l1callback(struct dchannel *dch, u_int cmd)
l1_event(dch->l1, HW_POWERUP_IND); l1_event(dch->l1, HW_POWERUP_IND);
break; break;
case HW_DEACT_REQ: case HW_DEACT_REQ:
__skb_queue_head_init(&free_queue);
/* start deactivation */ /* start deactivation */
spin_lock_irqsave(&hc->lock, flags); spin_lock_irqsave(&hc->lock, flags);
if (hc->ctype == HFC_TYPE_E1) { if (hc->ctype == HFC_TYPE_E1) {
...@@ -3264,20 +3266,21 @@ hfcm_l1callback(struct dchannel *dch, u_int cmd) ...@@ -3264,20 +3266,21 @@ hfcm_l1callback(struct dchannel *dch, u_int cmd)
plxsd_checksync(hc, 0); plxsd_checksync(hc, 0);
} }
} }
skb_queue_purge(&dch->squeue); skb_queue_splice_init(&dch->squeue, &free_queue);
if (dch->tx_skb) { if (dch->tx_skb) {
dev_kfree_skb(dch->tx_skb); __skb_queue_tail(&free_queue, dch->tx_skb);
dch->tx_skb = NULL; dch->tx_skb = NULL;
} }
dch->tx_idx = 0; dch->tx_idx = 0;
if (dch->rx_skb) { if (dch->rx_skb) {
dev_kfree_skb(dch->rx_skb); __skb_queue_tail(&free_queue, dch->rx_skb);
dch->rx_skb = NULL; dch->rx_skb = NULL;
} }
test_and_clear_bit(FLG_TX_BUSY, &dch->Flags); test_and_clear_bit(FLG_TX_BUSY, &dch->Flags);
if (test_and_clear_bit(FLG_BUSY_TIMER, &dch->Flags)) if (test_and_clear_bit(FLG_BUSY_TIMER, &dch->Flags))
del_timer(&dch->timer); del_timer(&dch->timer);
spin_unlock_irqrestore(&hc->lock, flags); spin_unlock_irqrestore(&hc->lock, flags);
__skb_queue_purge(&free_queue);
break; break;
case HW_POWERUP_REQ: case HW_POWERUP_REQ:
spin_lock_irqsave(&hc->lock, flags); spin_lock_irqsave(&hc->lock, flags);
...@@ -3384,6 +3387,9 @@ handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb) ...@@ -3384,6 +3387,9 @@ handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb)
case PH_DEACTIVATE_REQ: case PH_DEACTIVATE_REQ:
test_and_clear_bit(FLG_L2_ACTIVATED, &dch->Flags); test_and_clear_bit(FLG_L2_ACTIVATED, &dch->Flags);
if (dch->dev.D.protocol != ISDN_P_TE_S0) { if (dch->dev.D.protocol != ISDN_P_TE_S0) {
struct sk_buff_head free_queue;
__skb_queue_head_init(&free_queue);
spin_lock_irqsave(&hc->lock, flags); spin_lock_irqsave(&hc->lock, flags);
if (debug & DEBUG_HFCMULTI_MSG) if (debug & DEBUG_HFCMULTI_MSG)
printk(KERN_DEBUG printk(KERN_DEBUG
...@@ -3405,14 +3411,14 @@ handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb) ...@@ -3405,14 +3411,14 @@ handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb)
/* deactivate */ /* deactivate */
dch->state = 1; dch->state = 1;
} }
skb_queue_purge(&dch->squeue); skb_queue_splice_init(&dch->squeue, &free_queue);
if (dch->tx_skb) { if (dch->tx_skb) {
dev_kfree_skb(dch->tx_skb); __skb_queue_tail(&free_queue, dch->tx_skb);
dch->tx_skb = NULL; dch->tx_skb = NULL;
} }
dch->tx_idx = 0; dch->tx_idx = 0;
if (dch->rx_skb) { if (dch->rx_skb) {
dev_kfree_skb(dch->rx_skb); __skb_queue_tail(&free_queue, dch->rx_skb);
dch->rx_skb = NULL; dch->rx_skb = NULL;
} }
test_and_clear_bit(FLG_TX_BUSY, &dch->Flags); test_and_clear_bit(FLG_TX_BUSY, &dch->Flags);
...@@ -3424,6 +3430,7 @@ handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb) ...@@ -3424,6 +3430,7 @@ handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb)
#endif #endif
ret = 0; ret = 0;
spin_unlock_irqrestore(&hc->lock, flags); spin_unlock_irqrestore(&hc->lock, flags);
__skb_queue_purge(&free_queue);
} else } else
ret = l1_event(dch->l1, hh->prim); ret = l1_event(dch->l1, hh->prim);
break; break;
......
...@@ -1617,16 +1617,19 @@ hfcpci_l2l1D(struct mISDNchannel *ch, struct sk_buff *skb) ...@@ -1617,16 +1617,19 @@ hfcpci_l2l1D(struct mISDNchannel *ch, struct sk_buff *skb)
test_and_clear_bit(FLG_L2_ACTIVATED, &dch->Flags); test_and_clear_bit(FLG_L2_ACTIVATED, &dch->Flags);
spin_lock_irqsave(&hc->lock, flags); spin_lock_irqsave(&hc->lock, flags);
if (hc->hw.protocol == ISDN_P_NT_S0) { if (hc->hw.protocol == ISDN_P_NT_S0) {
struct sk_buff_head free_queue;
__skb_queue_head_init(&free_queue);
/* prepare deactivation */ /* prepare deactivation */
Write_hfc(hc, HFCPCI_STATES, 0x40); Write_hfc(hc, HFCPCI_STATES, 0x40);
skb_queue_purge(&dch->squeue); skb_queue_splice_init(&dch->squeue, &free_queue);
if (dch->tx_skb) { if (dch->tx_skb) {
dev_kfree_skb(dch->tx_skb); __skb_queue_tail(&free_queue, dch->tx_skb);
dch->tx_skb = NULL; dch->tx_skb = NULL;
} }
dch->tx_idx = 0; dch->tx_idx = 0;
if (dch->rx_skb) { if (dch->rx_skb) {
dev_kfree_skb(dch->rx_skb); __skb_queue_tail(&free_queue, dch->rx_skb);
dch->rx_skb = NULL; dch->rx_skb = NULL;
} }
test_and_clear_bit(FLG_TX_BUSY, &dch->Flags); test_and_clear_bit(FLG_TX_BUSY, &dch->Flags);
...@@ -1639,10 +1642,12 @@ hfcpci_l2l1D(struct mISDNchannel *ch, struct sk_buff *skb) ...@@ -1639,10 +1642,12 @@ hfcpci_l2l1D(struct mISDNchannel *ch, struct sk_buff *skb)
hc->hw.mst_m &= ~HFCPCI_MASTER; hc->hw.mst_m &= ~HFCPCI_MASTER;
Write_hfc(hc, HFCPCI_MST_MODE, hc->hw.mst_m); Write_hfc(hc, HFCPCI_MST_MODE, hc->hw.mst_m);
ret = 0; ret = 0;
spin_unlock_irqrestore(&hc->lock, flags);
__skb_queue_purge(&free_queue);
} else { } else {
ret = l1_event(dch->l1, hh->prim); ret = l1_event(dch->l1, hh->prim);
spin_unlock_irqrestore(&hc->lock, flags);
} }
spin_unlock_irqrestore(&hc->lock, flags);
break; break;
} }
if (!ret) if (!ret)
......
...@@ -326,20 +326,24 @@ hfcusb_l2l1D(struct mISDNchannel *ch, struct sk_buff *skb) ...@@ -326,20 +326,24 @@ hfcusb_l2l1D(struct mISDNchannel *ch, struct sk_buff *skb)
test_and_clear_bit(FLG_L2_ACTIVATED, &dch->Flags); test_and_clear_bit(FLG_L2_ACTIVATED, &dch->Flags);
if (hw->protocol == ISDN_P_NT_S0) { if (hw->protocol == ISDN_P_NT_S0) {
struct sk_buff_head free_queue;
__skb_queue_head_init(&free_queue);
hfcsusb_ph_command(hw, HFC_L1_DEACTIVATE_NT); hfcsusb_ph_command(hw, HFC_L1_DEACTIVATE_NT);
spin_lock_irqsave(&hw->lock, flags); spin_lock_irqsave(&hw->lock, flags);
skb_queue_purge(&dch->squeue); skb_queue_splice_init(&dch->squeue, &free_queue);
if (dch->tx_skb) { if (dch->tx_skb) {
dev_kfree_skb(dch->tx_skb); __skb_queue_tail(&free_queue, dch->tx_skb);
dch->tx_skb = NULL; dch->tx_skb = NULL;
} }
dch->tx_idx = 0; dch->tx_idx = 0;
if (dch->rx_skb) { if (dch->rx_skb) {
dev_kfree_skb(dch->rx_skb); __skb_queue_tail(&free_queue, dch->rx_skb);
dch->rx_skb = NULL; dch->rx_skb = NULL;
} }
test_and_clear_bit(FLG_TX_BUSY, &dch->Flags); test_and_clear_bit(FLG_TX_BUSY, &dch->Flags);
spin_unlock_irqrestore(&hw->lock, flags); spin_unlock_irqrestore(&hw->lock, flags);
__skb_queue_purge(&free_queue);
#ifdef FIXME #ifdef FIXME
if (test_and_clear_bit(FLG_L1_BUSY, &dch->Flags)) if (test_and_clear_bit(FLG_L1_BUSY, &dch->Flags))
dchannel_sched_event(&hc->dch, D_CLEARBUSY); dchannel_sched_event(&hc->dch, D_CLEARBUSY);
...@@ -1330,7 +1334,7 @@ tx_iso_complete(struct urb *urb) ...@@ -1330,7 +1334,7 @@ tx_iso_complete(struct urb *urb)
printk("\n"); printk("\n");
} }
dev_kfree_skb(tx_skb); dev_consume_skb_irq(tx_skb);
tx_skb = NULL; tx_skb = NULL;
if (fifo->dch && get_next_dframe(fifo->dch)) if (fifo->dch && get_next_dframe(fifo->dch))
tx_skb = fifo->dch->tx_skb; tx_skb = fifo->dch->tx_skb;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment