diff options
author | Jiang Liu <jiang.liu@linux.intel.com> | 2014-01-06 01:18:11 -0500 |
---|---|---|
committer | Joerg Roedel <joro@8bytes.org> | 2014-01-09 06:43:25 -0500 |
commit | 852bdb04f81c276969d43b9e15048259d028881f (patch) | |
tree | a96c2e20284c9f80e96d6114b2511f8575318a94 /drivers/iommu/intel-iommu.c | |
parent | 18d99165d3ebe5e365de57bcc673901d754c7142 (diff) |
iommu/vt-d: fix resource leakage on error recovery path in iommu_init_domains()
Release allocated resources on error recovery path in function
iommu_init_domains().
Also improve printk messages in iommu_init_domains().
Acked-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Signed-off-by: Joerg Roedel <joro@8bytes.org>
Diffstat (limited to 'drivers/iommu/intel-iommu.c')
-rw-r--r-- | drivers/iommu/intel-iommu.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index e2d2cb3119b3..0cbf1dda0730 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c | |||
@@ -1255,8 +1255,8 @@ static int iommu_init_domains(struct intel_iommu *iommu) | |||
1255 | unsigned long nlongs; | 1255 | unsigned long nlongs; |
1256 | 1256 | ||
1257 | ndomains = cap_ndoms(iommu->cap); | 1257 | ndomains = cap_ndoms(iommu->cap); |
1258 | pr_debug("IOMMU %d: Number of Domains supported <%ld>\n", iommu->seq_id, | 1258 | pr_debug("IOMMU%d: Number of Domains supported <%ld>\n", |
1259 | ndomains); | 1259 | iommu->seq_id, ndomains); |
1260 | nlongs = BITS_TO_LONGS(ndomains); | 1260 | nlongs = BITS_TO_LONGS(ndomains); |
1261 | 1261 | ||
1262 | spin_lock_init(&iommu->lock); | 1262 | spin_lock_init(&iommu->lock); |
@@ -1266,13 +1266,17 @@ static int iommu_init_domains(struct intel_iommu *iommu) | |||
1266 | */ | 1266 | */ |
1267 | iommu->domain_ids = kcalloc(nlongs, sizeof(unsigned long), GFP_KERNEL); | 1267 | iommu->domain_ids = kcalloc(nlongs, sizeof(unsigned long), GFP_KERNEL); |
1268 | if (!iommu->domain_ids) { | 1268 | if (!iommu->domain_ids) { |
1269 | printk(KERN_ERR "Allocating domain id array failed\n"); | 1269 | pr_err("IOMMU%d: allocating domain id array failed\n", |
1270 | iommu->seq_id); | ||
1270 | return -ENOMEM; | 1271 | return -ENOMEM; |
1271 | } | 1272 | } |
1272 | iommu->domains = kcalloc(ndomains, sizeof(struct dmar_domain *), | 1273 | iommu->domains = kcalloc(ndomains, sizeof(struct dmar_domain *), |
1273 | GFP_KERNEL); | 1274 | GFP_KERNEL); |
1274 | if (!iommu->domains) { | 1275 | if (!iommu->domains) { |
1275 | printk(KERN_ERR "Allocating domain array failed\n"); | 1276 | pr_err("IOMMU%d: allocating domain array failed\n", |
1277 | iommu->seq_id); | ||
1278 | kfree(iommu->domain_ids); | ||
1279 | iommu->domain_ids = NULL; | ||
1276 | return -ENOMEM; | 1280 | return -ENOMEM; |
1277 | } | 1281 | } |
1278 | 1282 | ||