public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: [patch] staging: slicoss: restore IRQs correctly after slic_cmdq_reset()
Date: Tue, 19 May 2015 12:25:24 +0000	[thread overview]
Message-ID: <20150519122524.GA2989@mwanda> (raw)

We can't save two different values in "flags" so it means that IRQs are
not enabled properly at the end of this function.  This isn't a problem
in the current code because it's always called with IRQs disabled so we
don't want to enable them at the end.

This bug is old but it's thanks to David Matlack's recent cleanups that
Smatch can detect it.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
The code prior to David Matlack's change was way worse because everyone
shared the same IRQ flags.  It's hard to imagine how it worked at all.

diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c
index 5f34ebbf..a609f3e 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -1392,7 +1392,7 @@ static void slic_cmdq_reset(struct adapter *adapter)
 	unsigned long flags;
 
 	spin_lock_irqsave(&adapter->cmdq_free.lock, flags);
-	spin_lock_irqsave(&adapter->cmdq_done.lock, flags);
+	spin_lock(&adapter->cmdq_done.lock);
 	outstanding = adapter->cmdq_all.count - adapter->cmdq_done.count;
 	outstanding -= adapter->cmdq_free.count;
 	hcmd = adapter->cmdq_all.head;
@@ -1423,7 +1423,7 @@ static void slic_cmdq_reset(struct adapter *adapter)
 			"free_count %d != all count %d\n",
 			adapter->cmdq_free.count, adapter->cmdq_all.count);
 	}
-	spin_unlock_irqrestore(&adapter->cmdq_done.lock, flags);
+	spin_unlock(&adapter->cmdq_done.lock);
 	spin_unlock_irqrestore(&adapter->cmdq_free.lock, flags);
 }
 

             reply	other threads:[~2015-05-19 12:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-19 12:25 Dan Carpenter [this message]
2015-05-26 16:59 ` [patch] staging: slicoss: restore IRQs correctly after slic_cmdq_reset() David Matlack

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=20150519122524.GA2989@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    /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