diff options
-rw-r--r-- | 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 fa5a1474cd18..8a9aaa8412c9 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, | |||
1487 | struct protection_domain *domain) | 1487 | struct protection_domain *domain) |
1488 | { | 1488 | { |
1489 | struct iommu_dev_data *dev_data, *alias_data; | 1489 | struct iommu_dev_data *dev_data, *alias_data; |
1490 | int ret; | ||
1490 | 1491 | ||
1491 | dev_data = get_dev_data(dev); | 1492 | dev_data = get_dev_data(dev); |
1492 | alias_data = get_dev_data(dev_data->alias); | 1493 | alias_data = get_dev_data(dev_data->alias); |
@@ -1498,13 +1499,14 @@ static int __attach_device(struct device *dev, | |||
1498 | spin_lock(&domain->lock); | 1499 | spin_lock(&domain->lock); |
1499 | 1500 | ||
1500 | /* Some sanity checks */ | 1501 | /* Some sanity checks */ |
1502 | ret = -EBUSY; | ||
1501 | if (alias_data->domain != NULL && | 1503 | if (alias_data->domain != NULL && |
1502 | alias_data->domain != domain) | 1504 | alias_data->domain != domain) |
1503 | return -EBUSY; | 1505 | goto out_unlock; |
1504 | 1506 | ||
1505 | if (dev_data->domain != NULL && | 1507 | if (dev_data->domain != NULL && |
1506 | dev_data->domain != domain) | 1508 | dev_data->domain != domain) |
1507 | return -EBUSY; | 1509 | goto out_unlock; |
1508 | 1510 | ||
1509 | /* Do real assignment */ | 1511 | /* Do real assignment */ |
1510 | if (dev_data->alias != dev) { | 1512 | if (dev_data->alias != dev) { |
@@ -1520,10 +1522,14 @@ static int __attach_device(struct device *dev, | |||
1520 | 1522 | ||
1521 | atomic_inc(&dev_data->bind); | 1523 | atomic_inc(&dev_data->bind); |
1522 | 1524 | ||
1525 | ret = 0; | ||
1526 | |||
1527 | out_unlock: | ||
1528 | |||
1523 | /* ready */ | 1529 | /* ready */ |
1524 | spin_unlock(&domain->lock); | 1530 | spin_unlock(&domain->lock); |
1525 | 1531 | ||
1526 | return 0; | 1532 | return ret; |
1527 | } | 1533 | } |
1528 | 1534 | ||
1529 | /* | 1535 | /* |