From patchwork Fri Jul 30 17:14:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gregkh@suse.de X-Patchwork-Id: 60371 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 68ED2B715C for ; Sat, 31 Jul 2010 03:18:39 +1000 (EST) Received: by ozlabs.org (Postfix) id AA7F0B6F14; Sat, 31 Jul 2010 03:18:31 +1000 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from coco.kroah.org (kroah.org [198.145.64.141]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "coco.kroah.org", Issuer "Greg KH" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 7A2DFB6EFE for ; Sat, 31 Jul 2010 03:18:31 +1000 (EST) Received: from localhost (c-24-16-163-131.hsd1.wa.comcast.net [24.16.163.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by coco.kroah.org (Postfix) with ESMTPSA id 6534248A8E; Fri, 30 Jul 2010 10:18:29 -0700 (PDT) X-Mailbox-Line: From gregkh@clark.site Fri Jul 30 10:15:04 2010 Message-Id: <20100730171504.200218674@clark.site> User-Agent: quilt/0.48-11.2 Date: Fri, 30 Jul 2010 10:14:38 -0700 From: Greg KH To: linux-kernel@vger.kernel.org, stable@kernel.org Subject: [050/165] genirq: Deal with desc->set_type() changing desc->chip In-Reply-To: <20100730171550.GA1299@kroah.com Cc: stable-review@kernel.org, linuxppc-dev , Thomas Gleixner , torvalds@linux-foundation.org, akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org 2.6.32-stable review patch. If anyone has any objections, please let us know. ------------------ From: Thomas Gleixner commit 4673247562e39a17e09440fa1400819522ccd446 upstream. The set_type() function can change the chip implementation when the trigger mode changes. That might result in using an non-initialized irq chip when called from __setup_irq() or when called via set_irq_type() on an already enabled irq. The set_irq_type() function should not be called on an enabled irq, but because we forgot to put a check into it, we have a bunch of users which grew the habit of doing that and it never blew up as the function is serialized via desc->lock against all users of desc->chip and they never hit the non-initialized irq chip issue. The easy fix for the __setup_irq() issue would be to move the irq_chip_set_defaults(desc->chip) call after the trigger setting to make sure that a chip change is covered. But as we have already users, which do the type setting after request_irq(), the safe fix for now is to call irq_chip_set_defaults() from __irq_set_trigger() when desc->set_type() changed the irq chip. It needs a deeper analysis whether we should refuse to change the chip on an already enabled irq, but that'd be a large scale change to fix all the existing users. So that's neither stable nor 2.6.35 material. Reported-by: Esben Haabendal Signed-off-by: Thomas Gleixner Cc: Benjamin Herrenschmidt Cc: linuxppc-dev Signed-off-by: Greg Kroah-Hartman --- kernel/irq/manage.c | 3 +++ 1 file changed, 3 insertions(+) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -436,6 +436,9 @@ int __irq_set_trigger(struct irq_desc *d /* note that IRQF_TRIGGER_MASK == IRQ_TYPE_SENSE_MASK */ desc->status &= ~(IRQ_LEVEL | IRQ_TYPE_SENSE_MASK); desc->status |= flags; + + if (chip != desc->chip) + irq_chip_set_defaults(desc->chip); } return ret;