Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1463800

[PATCH] smc91c92_cs : add a spinlock to avoid race condition

From Pavel Andrianov <andrianov@ispras.ru>
Newsgroups linux.kernel
Subject [PATCH] smc91c92_cs : add a spinlock to avoid race condition
Date 2016-08-16 15:40 +0200
Message-ID <s6ML1-3GS-55@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


smc_reset may be executed in parallel with timer function media_check.
To avoid data race in smc_set_xcvr a spinlock was added.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Pavel Andrianov <andrianov@ispras.ru>
---
 drivers/net/ethernet/smsc/smc91c92_cs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/smsc/smc91c92_cs.c b/drivers/net/ethernet/smsc/smc91c92_cs.c
index db3c696..69d865c 100644
--- a/drivers/net/ethernet/smsc/smc91c92_cs.c
+++ b/drivers/net/ethernet/smsc/smc91c92_cs.c
@@ -1637,6 +1637,7 @@ static void smc_reset(struct net_device *dev)
     unsigned int ioaddr = dev->base_addr;
     struct smc_private *smc = netdev_priv(dev);
     int i;
+    unsigned long flags;
 
     netdev_dbg(dev, "smc91c92 reset called.\n");
 
@@ -1647,6 +1648,7 @@ static void smc_reset(struct net_device *dev)
     outw(RCR_SOFTRESET, ioaddr + RCR);
     udelay(10);
 
+    spin_lock_irqsave(&smc->lock, flags);
     /* Clear the transmit and receive configuration registers. */
     outw(RCR_CLEAR, ioaddr + RCR);
     outw(TCR_CLEAR, ioaddr + TCR);
@@ -1699,6 +1701,7 @@ static void smc_reset(struct net_device *dev)
     SMC_SELECT_BANK(2);
     outw((IM_EPH_INT | IM_RX_OVRN_INT | IM_RCV_INT) << 8,
 	 ioaddr + INTERRUPT);
+    spin_unlock_irqrestore(&smc->lock, flags);
 }
 
 /*======================================================================
-- 
2.7.4

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] smc91c92_cs : add a spinlock to avoid race condition Pavel Andrianov <andrianov@ispras.ru> - 2016-08-16 15:40 +0200
  Re: [PATCH] smc91c92_cs : add a spinlock to avoid race condition David Miller <davem@davemloft.net> - 2016-08-19 06:10 +0200
    Re: [PATCH] smc91c92_cs : add a spinlock to avoid race condition Vaishali Thakkar <vaishali.thakkar@oracle.com> - 2016-08-19 06:50 +0200
      Re: [PATCH] smc91c92_cs : add a spinlock to avoid race condition David Miller <davem@davemloft.net> - 2016-08-19 08:10 +0200

csiph-web