linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 6/17] arch/x86/kernel: Add missing spin_unlock
@ 2010-05-26 15:55 Julia Lawall
  2010-05-27 11:06 ` Roedel, Joerg
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Julia Lawall @ 2010-05-26 15:55 UTC (permalink / raw)
  To: Joerg Roedel, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
	iommu, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

Add a spin_unlock missing on the error path.  The locks and unlocks are
balanced in other functions, so it seems that the same should be the case
here.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression E1;
@@

* spin_lock(E1,...);
  <+... when != E1
  if (...) {
    ... when != E1
*   return ...;
  }
  ...+>
* spin_unlock(E1,...);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 arch/x86/kernel/amd_iommu.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index fa5a147..b98e1cd 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -1499,12 +1499,16 @@ static int __attach_device(struct device *dev,
 
 	/* Some sanity checks */
 	if (alias_data->domain != NULL &&
-	    alias_data->domain != domain)
+	    alias_data->domain != domain) {
+		spin_unlock(&domain->lock);
 		return -EBUSY;
+	}
 
 	if (dev_data->domain != NULL &&
-	    dev_data->domain != domain)
+	    dev_data->domain != domain) {
+		spin_unlock(&domain->lock);
 		return -EBUSY;
+	}
 
 	/* Do real assignment */
 	if (dev_data->alias != dev) {

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2010-06-02  8:42 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-26 15:55 [PATCH 6/17] arch/x86/kernel: Add missing spin_unlock Julia Lawall
2010-05-27 11:06 ` Roedel, Joerg
2010-05-27 11:11 ` Roedel, Joerg
2010-05-27 11:17   ` Julia Lawall
2010-05-27 11:42     ` Nicolas Palix
2010-05-28  7:11       ` Roedel, Joerg
2010-05-28 16:45         ` H. Peter Anvin
2010-06-01  9:58           ` Joerg Roedel
2010-06-01 21:15 ` Andrew Morton
2010-06-01 21:47   ` Thomas Gleixner
2010-06-02  5:29   ` Julia Lawall
2010-06-02  8:38   ` Roedel, Joerg
2010-06-02  8:42     ` Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).