From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965090AbcAZKcO (ORCPT ); Tue, 26 Jan 2016 05:32:14 -0500 Received: from foss.arm.com ([217.140.101.70]:43815 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933988AbcAZKcL (ORCPT ); Tue, 26 Jan 2016 05:32:11 -0500 From: Brian Starkey To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, marc.zyngier@arm.com Subject: [PATCH] genirq: fix trigger flags check for shared irqs Date: Tue, 26 Jan 2016 10:31:54 +0000 Message-Id: <96c068ece0f5d01fc85bdbd9e0798f68180eebb8.1453204950.git.brian.starkey@arm.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For shared interrupts, if one requester passes in any IRQF_TRIGGER_* flags whilst another doesn't, __setup_irq() can erroneously fail. The no-flags case should be treated as "already configured", so change __setup_irq() to only check that the flags match if any have been provided. Signed-off-by: Brian Starkey Reviewed-by: Marc Zyngier --- kernel/irq/manage.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index a79d267..032c8fa 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -995,14 +995,10 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) old = *old_ptr; if (old) { /* - * Can't share interrupts unless both agree to and are - * the same type (level, edge, polarity). So both flag - * fields must have IRQF_SHARED set and the bits which - * set the trigger type must match. Also all must - * agree on ONESHOT. + * Can't share interrupts unless both agree to and all + * must agree on ONESHOT */ if (!((old->flags & new->flags) & IRQF_SHARED) || - ((old->flags ^ new->flags) & IRQF_TRIGGER_MASK) || ((old->flags ^ new->flags) & IRQF_ONESHOT)) goto mismatch; @@ -1014,6 +1010,15 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) /* add new interrupt at end of irq queue */ do { /* + * If 'new' requests a trigger type it must match all + * previously requested trigger types. + */ + if (((new->flags & IRQF_TRIGGER_MASK) && + (old->flags & IRQF_TRIGGER_MASK)) && + ((new->flags ^ old->flags) & IRQF_TRIGGER_MASK)) + goto mismatch; + + /* * Or all existing action->thread_mask bits, * so we can find the next zero bit for this * new action. -- 1.7.9.5