Skip to content

Commit 56c6be3

Browse files
Ychamekuba-moo
authored andcommitted
mISDN: hfcpci: Fix potential deadlock on &hc->lock
As &hc->lock is acquired by both timer _hfcpci_softirq() and hardirq hfcpci_int(), the timer should disable irq before lock acquisition otherwise deadlock could happen if the timmer is preemtped by the hadr irq. Possible deadlock scenario: hfcpci_softirq() (timer) -> _hfcpci_softirq() -> spin_lock(&hc->lock); <irq interruption> -> hfcpci_int() -> spin_lock(&hc->lock); (deadlock here) This flaw was found by an experimental static analysis tool I am developing for irq-related deadlock. The tentative patch fixes the potential deadlock by spin_lock_irq() in timer. Fixes: b36b654 ("mISDN: Create /sys/class/mISDN") Signed-off-by: Chengfeng Ye <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e68409d commit 56c6be3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/isdn/hardware/mISDN/hfcpci.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ hfcpci_fill_fifo(struct bchannel *bch)
839839
*z1t = cpu_to_le16(new_z1); /* now send data */
840840
if (bch->tx_idx < bch->tx_skb->len)
841841
return;
842-
dev_kfree_skb(bch->tx_skb);
842+
dev_kfree_skb_any(bch->tx_skb);
843843
if (get_next_bframe(bch))
844844
goto next_t_frame;
845845
return;
@@ -895,7 +895,7 @@ hfcpci_fill_fifo(struct bchannel *bch)
895895
}
896896
bz->za[new_f1].z1 = cpu_to_le16(new_z1); /* for next buffer */
897897
bz->f1 = new_f1; /* next frame */
898-
dev_kfree_skb(bch->tx_skb);
898+
dev_kfree_skb_any(bch->tx_skb);
899899
get_next_bframe(bch);
900900
}
901901

@@ -1119,7 +1119,7 @@ tx_birq(struct bchannel *bch)
11191119
if (bch->tx_skb && bch->tx_idx < bch->tx_skb->len)
11201120
hfcpci_fill_fifo(bch);
11211121
else {
1122-
dev_kfree_skb(bch->tx_skb);
1122+
dev_kfree_skb_any(bch->tx_skb);
11231123
if (get_next_bframe(bch))
11241124
hfcpci_fill_fifo(bch);
11251125
}
@@ -2277,7 +2277,7 @@ _hfcpci_softirq(struct device *dev, void *unused)
22772277
return 0;
22782278

22792279
if (hc->hw.int_m2 & HFCPCI_IRQ_ENABLE) {
2280-
spin_lock(&hc->lock);
2280+
spin_lock_irq(&hc->lock);
22812281
bch = Sel_BCS(hc, hc->hw.bswapped ? 2 : 1);
22822282
if (bch && bch->state == ISDN_P_B_RAW) { /* B1 rx&tx */
22832283
main_rec_hfcpci(bch);
@@ -2288,7 +2288,7 @@ _hfcpci_softirq(struct device *dev, void *unused)
22882288
main_rec_hfcpci(bch);
22892289
tx_birq(bch);
22902290
}
2291-
spin_unlock(&hc->lock);
2291+
spin_unlock_irq(&hc->lock);
22922292
}
22932293
return 0;
22942294
}

0 commit comments

Comments
 (0)