All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Heiko Stübner" <heiko@sntech.de>
To: Kukjin Kim <kgene.kim@samsung.com>
Cc: Julia Lawall <julia.lawall@lip6.fr>,
	linux-samsung-soc@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/5] ARM: S3C24XX: fix redundant checks in the irq mapping function
Date: Tue, 26 Feb 2013 23:57:53 +0100	[thread overview]
Message-ID: <201302262357.53354.heiko@sntech.de> (raw)
In-Reply-To: <201302262357.24544.heiko@sntech.de>

The check during the parent handling itself was wrong, as it should have
checked for parent_irq_data.

The interrupt controller structs always contain an irq_data array with 32
entries and the only possible error could be a parent_irq assignment of >31.

As this would point to outside the irq_data array this could contain
anything including non-NULL values. Therefore correct this to check
the parent_irq value to be in the right range.

With the same explanation of a valid interrupt controller always having a
full irq_data array, the topmost irq_data check in s3c24xx_irq_map
can also go away.

Finally the mapping function is only called thru the irq_domain ops, in
which case the intc struct is already successfully created, so there is
no need to check for it again.

Reported-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 arch/arm/mach-s3c24xx/irq.c |   18 ++++--------------
 1 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-s3c24xx/irq.c b/arch/arm/mach-s3c24xx/irq.c
index 3f3de74..5257c9f 100644
--- a/arch/arm/mach-s3c24xx/irq.c
+++ b/arch/arm/mach-s3c24xx/irq.c
@@ -324,16 +324,6 @@ static int s3c24xx_irq_map(struct irq_domain *h, unsigned 
int virq,
 	struct s3c_irq_data *parent_irq_data;
 	unsigned int irqno;
 
-	if (!intc) {
-		pr_err("irq-s3c24xx: no controller found for hwirq %lu\n", hw);
-		return -EINVAL;
-	}
-
-	if (!irq_data) {
-		pr_err("irq-s3c24xx: no irq data found for hwirq %lu\n", hw);
-		return -EINVAL;
-	}
-
 	/* attach controller pointer to irq_data */
 	irq_data->intc = intc;
 
@@ -383,13 +373,13 @@ static int s3c24xx_irq_map(struct irq_domain *h, 
unsigned int virq,
 			goto err;
 		}
 
-		parent_irq_data = &parent_intc->irqs[irq_data->parent_irq];
-		if (!irq_data) {
-			pr_err("irq-s3c24xx: no irq data found for hwirq %lu\n",
-			       hw);
+		if (irq_data->parent_irq > 31) {
+			pr_err("irq-s3c24xx: parent irq %lu is out of range\n",
+			       irq_data->parent_irq);
 			goto err;
 		}
 
+		parent_irq_data = &parent_intc->irqs[irq_data->parent_irq];
 		parent_irq_data->sub_intc = intc;
 		parent_irq_data->sub_bits |= (1UL << hw);
 
-- 
1.7.2.3

WARNING: multiple messages have this Message-ID (diff)
From: heiko@sntech.de (Heiko Stübner)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/5] ARM: S3C24XX: fix redundant checks in the irq mapping function
Date: Tue, 26 Feb 2013 23:57:53 +0100	[thread overview]
Message-ID: <201302262357.53354.heiko@sntech.de> (raw)
In-Reply-To: <201302262357.24544.heiko@sntech.de>

The check during the parent handling itself was wrong, as it should have
checked for parent_irq_data.

The interrupt controller structs always contain an irq_data array with 32
entries and the only possible error could be a parent_irq assignment of >31.

As this would point to outside the irq_data array this could contain
anything including non-NULL values. Therefore correct this to check
the parent_irq value to be in the right range.

With the same explanation of a valid interrupt controller always having a
full irq_data array, the topmost irq_data check in s3c24xx_irq_map
can also go away.

Finally the mapping function is only called thru the irq_domain ops, in
which case the intc struct is already successfully created, so there is
no need to check for it again.

Reported-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 arch/arm/mach-s3c24xx/irq.c |   18 ++++--------------
 1 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-s3c24xx/irq.c b/arch/arm/mach-s3c24xx/irq.c
index 3f3de74..5257c9f 100644
--- a/arch/arm/mach-s3c24xx/irq.c
+++ b/arch/arm/mach-s3c24xx/irq.c
@@ -324,16 +324,6 @@ static int s3c24xx_irq_map(struct irq_domain *h, unsigned 
int virq,
 	struct s3c_irq_data *parent_irq_data;
 	unsigned int irqno;
 
-	if (!intc) {
-		pr_err("irq-s3c24xx: no controller found for hwirq %lu\n", hw);
-		return -EINVAL;
-	}
-
-	if (!irq_data) {
-		pr_err("irq-s3c24xx: no irq data found for hwirq %lu\n", hw);
-		return -EINVAL;
-	}
-
 	/* attach controller pointer to irq_data */
 	irq_data->intc = intc;
 
@@ -383,13 +373,13 @@ static int s3c24xx_irq_map(struct irq_domain *h, 
unsigned int virq,
 			goto err;
 		}
 
-		parent_irq_data = &parent_intc->irqs[irq_data->parent_irq];
-		if (!irq_data) {
-			pr_err("irq-s3c24xx: no irq data found for hwirq %lu\n",
-			       hw);
+		if (irq_data->parent_irq > 31) {
+			pr_err("irq-s3c24xx: parent irq %lu is out of range\n",
+			       irq_data->parent_irq);
 			goto err;
 		}
 
+		parent_irq_data = &parent_intc->irqs[irq_data->parent_irq];
 		parent_irq_data->sub_intc = intc;
 		parent_irq_data->sub_bits |= (1UL << hw);
 
-- 
1.7.2.3

  reply	other threads:[~2013-02-26 22:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-26 22:57 [PATCH 0/5] ARM: S3C24XX: more fixes and enhancements for the s3c24xx irqs Heiko Stübner
2013-02-26 22:57 ` Heiko Stübner
2013-02-26 22:57 ` Heiko Stübner [this message]
2013-02-26 22:57   ` [PATCH 1/5] ARM: S3C24XX: fix redundant checks in the irq mapping function Heiko Stübner
2013-02-26 22:58 ` [PATCH 2/5] ARM: S3C24XX: fix irq parent check Heiko Stübner
2013-02-26 22:58   ` Heiko Stübner
2013-02-26 22:58 ` [PATCH 3/5] ARM: S3C24XX: move s3c24xx_init_irq to s3c2410_init_irq Heiko Stübner
2013-02-26 22:58   ` Heiko Stübner
2013-02-26 22:59 ` [PATCH 4/5] ARM: S3C24XX: make s3c24xx_init_intc static Heiko Stübner
2013-02-26 22:59   ` Heiko Stübner
2013-02-26 23:00 ` [PATCH 5/5] ARM: S3C24XX: add handle_irq function Heiko Stübner
2013-02-26 23:00   ` Heiko Stübner
2013-03-09  9:14 ` [PATCH 0/5] ARM: S3C24XX: more fixes and enhancements for the s3c24xx irqs Kukjin Kim
2013-03-09  9:14   ` Kukjin Kim

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=201302262357.53354.heiko@sntech.de \
    --to=heiko@sntech.de \
    --cc=julia.lawall@lip6.fr \
    --cc=kgene.kim@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-samsung-soc@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.