From patchwork Tue Jun 16 22:06:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King X-Patchwork-Id: 485204 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 C68401402AB for ; Wed, 17 Jun 2015 08:07:00 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=arm.linux.org.uk header.i=@arm.linux.org.uk header.b=YNpLJnvB; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754269AbbFPWHA (ORCPT ); Tue, 16 Jun 2015 18:07:00 -0400 Received: from pandora.arm.linux.org.uk ([78.32.30.218]:35810 "EHLO pandora.arm.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752925AbbFPWG7 (ORCPT ); Tue, 16 Jun 2015 18:06:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=pandora-2014; h=Date:Sender:Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From; bh=NArIk8k6TwjCqAGgU29LFb9A1sdc5kleZ3Kkv7Zehp0=; b=YNpLJnvB8sCN1Fcoe2mq73sem3PMqXzo4DmKcsHfC3HqlOxqDkYGDB37xaBP5S7HCwRcSXZJgyCq2M2ANut2TNdeF+7XLDH/GfIGzixc/74GI7xlbAEFKmZZr3jYNmzn4ZUmpBcf1Ztlod+RjZzVJerRWZ8dqIFrvGqzKtGKhTA=; Received: from e0022681537dd.dyn.arm.linux.org.uk ([2001:4d48:ad52:3201:222:68ff:fe15:37dd]:51176 helo=rmk-PC.arm.linux.org.uk) by pandora.arm.linux.org.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1Z4z0J-000414-1q; Tue, 16 Jun 2015 23:06:47 +0100 Received: from rmk by rmk-PC.arm.linux.org.uk with local (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1Z4z0C-0002SX-Lj; Tue, 16 Jun 2015 23:06:40 +0100 From: Russell King To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-tegra@vger.kernel.org, Thomas Gleixner Cc: Alexandre Courbot , Hans Ulli Kroll , Jason Cooper , Lee Jones , Linus Walleij , Thierry Reding Subject: [PATCH 5/9] gpio: gpio-mxc: fix race in installing chained IRQ handler MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Tue, 16 Jun 2015 23:06:40 +0100 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Fix a race where a pending interrupt could be received and the handler called before the handler's data has been setup, by converting to irq_set_chained_handler_and_data(). Signed-off-by: Russell King --- Depends on patch 1. drivers/gpio/gpio-mxc.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c index 9f7446a7ac64..e4f42c95c320 100644 --- a/drivers/gpio/gpio-mxc.c +++ b/drivers/gpio/gpio-mxc.c @@ -437,14 +437,13 @@ static int mxc_gpio_probe(struct platform_device *pdev) irq_set_chained_handler(port->irq, mx2_gpio_irq_handler); } else { /* setup one handler for each entry */ - irq_set_chained_handler(port->irq, mx3_gpio_irq_handler); - irq_set_handler_data(port->irq, port); - if (port->irq_high > 0) { + irq_set_chained_handler_and_data(port->irq, + mx3_gpio_irq_handler, port); + if (port->irq_high > 0) /* setup handler for GPIO 16 to 31 */ - irq_set_chained_handler(port->irq_high, - mx3_gpio_irq_handler); - irq_set_handler_data(port->irq_high, port); - } + irq_set_chained_handler_and_data(port->irq_high, + mx3_gpio_irq_handler, + port); } err = bgpio_init(&port->bgc, &pdev->dev, 4,