Skip to content

Commit 73033c9

Browse files
edmitardavem330
authored andcommitted
caif-hsi: Fix for wakeup condition problem
Under stressed conditions a race could happen when del_timer_sync() was called from softirq context at the same time when mod_timer_pending() for the same timer was called from the workqueue. This leaded to a state mismatch in the CAIF HSI driver and following unexpected link wakeup procedure. The fix puts del_timer_sync() and mod_timer_pending() calls under a spin lock to protect against the race condition. Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent fe47f12 commit 73033c9

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎drivers/net/caif/caif_hsi.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,9 @@ static void cfhsi_rx_done_work(struct work_struct *work)
551551
return;
552552

553553
/* Update inactivity timer if pending. */
554+
spin_lock_bh(&cfhsi->lock);
554555
mod_timer_pending(&cfhsi->timer, jiffies + CFHSI_INACTIVITY_TOUT);
556+
spin_unlock_bh(&cfhsi->lock);
555557

556558
if (cfhsi->rx_state == CFHSI_RX_STATE_DESC) {
557559
desc_pld_len = cfhsi_rx_desc(desc, cfhsi);
@@ -866,10 +868,10 @@ static int cfhsi_xmit(struct sk_buff *skb, struct net_device *dev)
866868
start_xfer = 1;
867869
}
868870

869-
spin_unlock_bh(&cfhsi->lock);
870-
871-
if (!start_xfer)
871+
if (!start_xfer) {
872+
spin_unlock_bh(&cfhsi->lock);
872873
return 0;
874+
}
873875

874876
/* Delete inactivity timer if started. */
875877
#ifdef CONFIG_SMP
@@ -878,6 +880,8 @@ static int cfhsi_xmit(struct sk_buff *skb, struct net_device *dev)
878880
timer_active = del_timer(&cfhsi->timer);
879881
#endif /* CONFIG_SMP */
880882

883+
spin_unlock_bh(&cfhsi->lock);
884+
881885
if (timer_active) {
882886
struct cfhsi_desc *desc = (struct cfhsi_desc *)cfhsi->tx_buf;
883887
int len;

0 commit comments

Comments
 (0)