From: Joerg Roedel <joerg.roedel@amd.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: <iommu@lists.linux-foundation.org>,
<linux-kernel@vger.kernel.org>, Julia Lawall <julia@diku.dk>,
<stable@kernel.org>, Joerg Roedel <joerg.roedel@amd.com>
Subject: [PATCH 1/3] arch/x86/kernel: Add missing spin_unlock
Date: Tue, 1 Jun 2010 11:03:39 +0200 [thread overview]
Message-ID: <1275383021-20172-2-git-send-email-joerg.roedel@amd.com> (raw)
In-Reply-To: <1275383021-20172-1-git-send-email-joerg.roedel@amd.com>
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>
Cc: stable@kernel.org
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kernel/amd_iommu.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index fa5a147..8a9aaa8 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -1487,6 +1487,7 @@ static int __attach_device(struct device *dev,
struct protection_domain *domain)
{
struct iommu_dev_data *dev_data, *alias_data;
+ int ret;
dev_data = get_dev_data(dev);
alias_data = get_dev_data(dev_data->alias);
@@ -1498,13 +1499,14 @@ static int __attach_device(struct device *dev,
spin_lock(&domain->lock);
/* Some sanity checks */
+ ret = -EBUSY;
if (alias_data->domain != NULL &&
alias_data->domain != domain)
- return -EBUSY;
+ goto out_unlock;
if (dev_data->domain != NULL &&
dev_data->domain != domain)
- return -EBUSY;
+ goto out_unlock;
/* Do real assignment */
if (dev_data->alias != dev) {
@@ -1520,10 +1522,14 @@ static int __attach_device(struct device *dev,
atomic_inc(&dev_data->bind);
+ ret = 0;
+
+out_unlock:
+
/* ready */
spin_unlock(&domain->lock);
- return 0;
+ return ret;
}
/*
--
1.7.1
next prev parent reply other threads:[~2010-06-01 9:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-01 9:03 [git pull] amd iommu fixes for 2.6.35-rc1 Joerg Roedel
2010-06-01 9:03 ` Joerg Roedel [this message]
2010-06-01 9:03 ` [PATCH 2/3] x86/amd-iommu: Fix crash when request_mem_region fails Joerg Roedel
2010-06-01 9:03 ` [PATCH 3/3] x86/amd-iommu: Fall back to GART if initialization fails Joerg Roedel
2010-06-01 9:45 ` [git pull] amd iommu fixes for 2.6.35-rc1 Ingo Molnar
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=1275383021-20172-2-git-send-email-joerg.roedel@amd.com \
--to=joerg.roedel@amd.com \
--cc=iommu@lists.linux-foundation.org \
--cc=julia@diku.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=stable@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
Powered by JetHome