From patchwork Tue Feb 26 22:57:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Stuebner X-Patchwork-Id: 2188271 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 5C6883FCF2 for ; Tue, 26 Feb 2013 23:01:26 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1UATTI-0007X5-Sr; Tue, 26 Feb 2013 22:58:05 +0000 Received: from gloria.sntech.de ([95.129.55.99]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1UATTC-0007VQ-BD for linux-arm-kernel@lists.infradead.org; Tue, 26 Feb 2013 22:57:59 +0000 Received: from 146-52-52-115-dynip.superkabel.de ([146.52.52.115] helo=marty.localnet) by gloria.sntech.de with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1UATT9-0005D9-1P; Tue, 26 Feb 2013 23:57:55 +0100 From: Heiko =?utf-8?q?St=C3=BCbner?= To: Kukjin Kim Subject: [PATCH 1/5] ARM: S3C24XX: fix redundant checks in the irq mapping function Date: Tue, 26 Feb 2013 23:57:53 +0100 User-Agent: KMail/1.13.7 (Linux/3.2.0-3-686-pae; KDE/4.8.4; i686; ; ) References: <201302262357.24544.heiko@sntech.de> In-Reply-To: <201302262357.24544.heiko@sntech.de> MIME-Version: 1.0 Message-Id: <201302262357.53354.heiko@sntech.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130226_175758_602235_FEAA9201 X-CRM114-Status: GOOD ( 15.77 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Julia Lawall , linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 Signed-off-by: Heiko Stuebner --- arch/arm/mach-s3c24xx/irq.c | 18 ++++-------------- 1 files changed, 4 insertions(+), 14 deletions(-) @@ -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); 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;