mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-23 20:53:53 +08:00
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>
This commit is contained in:
parent
18d99165d3
commit
852bdb04f8
@ -1255,8 +1255,8 @@ static int iommu_init_domains(struct intel_iommu *iommu)
|
|||||||
unsigned long nlongs;
|
unsigned long nlongs;
|
||||||
|
|
||||||
ndomains = cap_ndoms(iommu->cap);
|
ndomains = cap_ndoms(iommu->cap);
|
||||||
pr_debug("IOMMU %d: Number of Domains supported <%ld>\n", iommu->seq_id,
|
pr_debug("IOMMU%d: Number of Domains supported <%ld>\n",
|
||||||
ndomains);
|
iommu->seq_id, ndomains);
|
||||||
nlongs = BITS_TO_LONGS(ndomains);
|
nlongs = BITS_TO_LONGS(ndomains);
|
||||||
|
|
||||||
spin_lock_init(&iommu->lock);
|
spin_lock_init(&iommu->lock);
|
||||||
@ -1266,13 +1266,17 @@ static int iommu_init_domains(struct intel_iommu *iommu)
|
|||||||
*/
|
*/
|
||||||
iommu->domain_ids = kcalloc(nlongs, sizeof(unsigned long), GFP_KERNEL);
|
iommu->domain_ids = kcalloc(nlongs, sizeof(unsigned long), GFP_KERNEL);
|
||||||
if (!iommu->domain_ids) {
|
if (!iommu->domain_ids) {
|
||||||
printk(KERN_ERR "Allocating domain id array failed\n");
|
pr_err("IOMMU%d: allocating domain id array failed\n",
|
||||||
|
iommu->seq_id);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
iommu->domains = kcalloc(ndomains, sizeof(struct dmar_domain *),
|
iommu->domains = kcalloc(ndomains, sizeof(struct dmar_domain *),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!iommu->domains) {
|
if (!iommu->domains) {
|
||||||
printk(KERN_ERR "Allocating domain array failed\n");
|
pr_err("IOMMU%d: allocating domain array failed\n",
|
||||||
|
iommu->seq_id);
|
||||||
|
kfree(iommu->domain_ids);
|
||||||
|
iommu->domain_ids = NULL;
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user