From b07a46456d9a97750c812aaa998626844c66ac47 Mon Sep 17 00:00:00 2001 From: Joerg Roedel Date: Wed, 26 Aug 2009 16:52:40 +0200 Subject: [PATCH] --- yaml --- r: 158079 b: refs/heads/master c: 2650815fb03fe2bf1e6701584087ba669dcf92cd h: refs/heads/master i: 158077: aaa93387f0d8b1bea0dc097fc088f93ba75b9a65 158075: fc0e0e8aabd8fed9b685411f47e840ff2260771d 158071: fc5f9a14f29fc0f49b0cd7d393fed2d67055bbb4 158063: e615db854bd74a220c0e931f82997712150e5784 158047: 5291ca3c4e279efe50036477b2ff60a535bd0dbc 158015: 3fdb908c0aca878113857172a9245908c8bb2ea8 157951: d733e1bc457848aff19c290bea7e0e1d74526ee7 v: v3 --- [refs] | 2 +- trunk/arch/x86/kernel/amd_iommu.c | 36 +++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index eff61fed1b84..56fc6917bb29 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: ac0101d396fee24994632f71b55b9f7f9ee16eff +refs/heads/master: 2650815fb03fe2bf1e6701584087ba669dcf92cd diff --git a/trunk/arch/x86/kernel/amd_iommu.c b/trunk/arch/x86/kernel/amd_iommu.c index 6c99f5037801..0934348abfad 100644 --- a/trunk/arch/x86/kernel/amd_iommu.c +++ b/trunk/arch/x86/kernel/amd_iommu.c @@ -1988,19 +1988,47 @@ static void cleanup_domain(struct protection_domain *domain) write_unlock_irqrestore(&amd_iommu_devtable_lock, flags); } -static int amd_iommu_domain_init(struct iommu_domain *dom) +static void protection_domain_free(struct protection_domain *domain) +{ + if (!domain) + return; + + if (domain->id) + domain_id_free(domain->id); + + kfree(domain); +} + +static struct protection_domain *protection_domain_alloc(void) { struct protection_domain *domain; domain = kzalloc(sizeof(*domain), GFP_KERNEL); if (!domain) - return -ENOMEM; + return NULL; spin_lock_init(&domain->lock); - domain->mode = PAGE_MODE_3_LEVEL; domain->id = domain_id_alloc(); if (!domain->id) + goto out_err; + + return domain; + +out_err: + kfree(domain); + + return NULL; +} + +static int amd_iommu_domain_init(struct iommu_domain *dom) +{ + struct protection_domain *domain; + + domain = protection_domain_alloc(); + if (!domain) goto out_free; + + domain->mode = PAGE_MODE_3_LEVEL; domain->pt_root = (void *)get_zeroed_page(GFP_KERNEL); if (!domain->pt_root) goto out_free; @@ -2010,7 +2038,7 @@ static int amd_iommu_domain_init(struct iommu_domain *dom) return 0; out_free: - kfree(domain); + protection_domain_free(domain); return -ENOMEM; }