Skip to content

Commit

Permalink
arch/x86/kernel: Add missing spin_unlock
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Julia Lawall authored and Joerg Roedel committed May 27, 2010
1 parent 795e74f commit 84fe6c1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions arch/x86/kernel/amd_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand All @@ -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;
}

/*
Expand Down

0 comments on commit 84fe6c1

Please sign in to comment.