linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joerg Roedel <joro@8bytes.org>
To: iommu@lists.linux-foundation.org
Cc: linux-kernel@vger.kernel.org, Joerg Roedel <jroedel@suse.de>
Subject: [PATCH 1/9] iommu/amd: Simplify allocation in irq_remapping_alloc()
Date: Thu, 13 Aug 2015 19:33:48 +0200	[thread overview]
Message-ID: <1439487236-14098-2-git-send-email-joro@8bytes.org> (raw)
In-Reply-To: <1439487236-14098-1-git-send-email-joro@8bytes.org>

From: Joerg Roedel <jroedel@suse.de>

Allocate the irq data only in the loop.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
 drivers/iommu/amd_iommu.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 658ee39..a158579 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -3947,11 +3947,6 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq,
 	if (ret < 0)
 		return ret;
 
-	ret = -ENOMEM;
-	data = kzalloc(sizeof(*data), GFP_KERNEL);
-	if (!data)
-		goto out_free_parent;
-
 	if (info->type == X86_IRQ_ALLOC_TYPE_IOAPIC) {
 		if (get_irq_table(devid, true))
 			index = info->ioapic_pin;
@@ -3962,7 +3957,6 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq,
 	}
 	if (index < 0) {
 		pr_warn("Failed to allocate IRTE\n");
-		kfree(data);
 		goto out_free_parent;
 	}
 
@@ -3974,17 +3968,18 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq,
 			goto out_free_data;
 		}
 
-		if (i > 0) {
-			data = kzalloc(sizeof(*data), GFP_KERNEL);
-			if (!data)
-				goto out_free_data;
-		}
+		ret = -ENOMEM;
+		data = kzalloc(sizeof(*data), GFP_KERNEL);
+		if (!data)
+			goto out_free_data;
+
 		irq_data->hwirq = (devid << 16) + i;
 		irq_data->chip_data = data;
 		irq_data->chip = &amd_ir_chip;
 		irq_remapping_prepare_irte(data, cfg, info, devid, index, i);
 		irq_set_status_flags(virq + i, IRQ_MOVE_PCNTXT);
 	}
+
 	return 0;
 
 out_free_data:
-- 
1.9.1


  reply	other threads:[~2015-08-13 17:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-13 17:33 [PATCH 0/9] iommu: Fix some static checker warnings Joerg Roedel
2015-08-13 17:33 ` Joerg Roedel [this message]
2015-08-13 17:33 ` [PATCH 2/9] iommu/amd: Make a symbol static Joerg Roedel
2015-08-13 17:33 ` [PATCH 3/9] iommu/amd: Use BUG_ON instead of if () BUG() Joerg Roedel
2015-08-13 17:33 ` [PATCH 4/9] iommu/vt-d: Return false instead of 0 in irq_remapping_cap() Joerg Roedel
2015-08-13 17:33 ` [PATCH 5/9] iommu/vt-d: Use BUG_ON instead of if () BUG() Joerg Roedel
2015-08-13 17:33 ` [PATCH 6/9] iommu/vt-d: Make two functions static Joerg Roedel
2015-08-13 17:33 ` [PATCH 7/9] iommu/vt-d: Access iomem correctly Joerg Roedel
2015-08-13 17:33 ` [PATCH 8/9] iommu/msm: Use BUG_ON instead of if () BUG() Joerg Roedel
2015-08-13 17:33 ` [PATCH 9/9] iommu/io-pgtable-arm: Move init-fn declarations to io-pgtable.h Joerg Roedel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1439487236-14098-2-git-send-email-joro@8bytes.org \
    --to=joro@8bytes.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jroedel@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).