mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pavel Andrianov <andrianov@ispras.ru>
To: Mugunthan V N <mugunthanvnm@ti.com>
Cc: Pavel Andrianov <andrianov@ispras.ru>,
	"David S. Miller" <davem@davemloft.net>,
	Antonio Quartulli <a@unstable.cc>,
	Felipe Balbi <felipe.balbi@linux.intel.com>,
	Florian Westphal <fw@strlen.de>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	vaishali.thakkar@oracle.com, ldv-project@linuxtesting.org
Subject: [PATCH] smc91c92_cs : add a spinlock to avoid race condition
Date: Tue, 16 Aug 2016 16:39:06 +0300	[thread overview]
Message-ID: <1471354746-27110-1-git-send-email-andrianov@ispras.ru> (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

             reply	other threads:[~2016-08-16 13:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-16 13:39 Pavel Andrianov [this message]
2016-08-19  4:07 ` David Miller
2016-08-19  4:41   ` Vaishali Thakkar
2016-08-19  6:00     ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1471354746-27110-1-git-send-email-andrianov@ispras.ru \
    --to=andrianov@ispras.ru \
    --cc=a@unstable.cc \
    --cc=davem@davemloft.net \
    --cc=felipe.balbi@linux.intel.com \
    --cc=fw@strlen.de \
    --cc=ldv-project@linuxtesting.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mugunthanvnm@ti.com \
    --cc=netdev@vger.kernel.org \
    --cc=vaishali.thakkar@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®