From patchwork Tue Sep 16 13:23:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Nikula X-Patchwork-Id: 390059 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E99AD1400E0 for ; Tue, 16 Sep 2014 23:23:36 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754116AbaIPNXV (ORCPT ); Tue, 16 Sep 2014 09:23:21 -0400 Received: from mga11.intel.com ([192.55.52.93]:37976 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753423AbaIPNXU (ORCPT ); Tue, 16 Sep 2014 09:23:20 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 16 Sep 2014 06:23:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,534,1406617200"; d="scan'208";a="600357384" Received: from mylly.fi.intel.com (HELO mylly.fi.intel.com.) ([10.237.72.56]) by fmsmga002.fm.intel.com with ESMTP; 16 Sep 2014 06:23:17 -0700 From: Jarkko Nikula To: Linus Walleij Cc: Alexandre Courbot , linux-gpio@vger.kernel.org, Mika Westerberg , Jarkko Nikula , Stable Subject: [PATCH] gpio: Fix potentially NULL handler data passed to chained irqchip handler Date: Tue, 16 Sep 2014 16:23:15 +0300 Message-Id: <1410873795-31980-1-git-send-email-jarkko.nikula@linux.intel.com> X-Mailer: git-send-email 2.1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org There is possibility with misconfigured pins that interrupt occurs instantly after setting irq_set_chained_handler() in gpiochip_set_chained_irqchip(). Now if handler gets called before irq_set_handler_data() the handler gets NULL handler data. Fix this by moving irq_set_handler_data() call before irq_set_chained_handler() in gpiochip_set_chained_irqchip(). Signed-off-by: Jarkko Nikula Cc: Stable # 3.15+ Reviewed-by: Alexandre Courbot --- I noticed this while debugging why commit e1ee5c578fb1 ("pinctrl: baytrail: Convert to use gpiolib irqchip") was showing a regression on a development machine with a few misconfigured pins by the BIOS. For those pins drivers/pinctrl/pinctrl-baytrail.c: byt_gpio_irq_handler() was often called instantly with handler data being NULL and dummy if (vg == NULL) return; test there didn't allow code further in byt_gpio_irq_handler() to disable those flooding pins. --- drivers/gpio/gpiolib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 15cc0bb65dda..ed3f518e4337 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -413,12 +413,12 @@ void gpiochip_set_chained_irqchip(struct gpio_chip *gpiochip, return; } - irq_set_chained_handler(parent_irq, parent_handler); /* * The parent irqchip is already using the chip_data for this * irqchip, so our callbacks simply use the handler_data. */ irq_set_handler_data(parent_irq, gpiochip); + irq_set_chained_handler(parent_irq, parent_handler); } EXPORT_SYMBOL_GPL(gpiochip_set_chained_irqchip);