Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751413AbdILJas (ORCPT ); Tue, 12 Sep 2017 05:30:48 -0400 Received: from mail-it0-f54.google.com ([209.85.214.54]:45967 "EHLO mail-it0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751286AbdILJap (ORCPT ); Tue, 12 Sep 2017 05:30:45 -0400 X-Google-Smtp-Source: AOwi7QDqytd9prrO2razKMrprVVZmh7H1oFJqM2b2ST7VC4Kxe9JH9rGJQ6HXwu9/NQ91+3bunOaSDcvvuDZSm5OYes= MIME-Version: 1.0 In-Reply-To: <20170907145407.32368-1-gregory.clement@free-electrons.com> References: <20170907145407.32368-1-gregory.clement@free-electrons.com> From: Linus Walleij Date: Tue, 12 Sep 2017 11:30:43 +0200 Message-ID: Subject: Re: [PATCH] pinctrl: armada-37xx: Fix gpio interrupt setup To: Gregory CLEMENT Cc: "linux-gpio@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Jason Cooper , Andrew Lunn , Sebastian Hesselbarth , Thomas Petazzoni , "linux-arm-kernel@lists.infradead.org" , Antoine Tenart , =?UTF-8?Q?Miqu=C3=A8l_Raynal?= , Nadav Haklai , Victor Gu , Marcin Wojtas , Wilson Ding , Hua Jing , Neta Zur Hershkovits , stable Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4215 Lines: 89 On Thu, Sep 7, 2017 at 4:54 PM, Gregory CLEMENT wrote: > Since commit dc749a09ea5e ("gpiolib: allow gpio irqchip to map irqs > dynamically"), the irqs for gpio are not statically allocated during in > gpiochip_irqchip_add. > > This driver was based on this assumption for initializing the mask > associated to each interrupt this led to a NULL pointer crash in the > kernel: > > Unable to handle kernel NULL pointer dereference at virtual address 00000000 > Mem abort info: > Exception class = DABT (current EL), IL = 32 bits > SET = 0, FnV = 0 > EA = 0, S1PTW = 0 > Data abort info: > ISV = 0, ISS = 0x00000068 > CM = 0, WnR = 1 > [0000000000000000] user address but active_mm is swapper > Internal error: Oops: 96000044 [#1] PREEMPT SMP > Modules linked in: > CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.13.0-06657-g3b9f8ed25dbe #576 > Hardware name: Marvell Armada 3720 Development Board DB-88F3720-DDR3 (DT) > task: ffff80001d908000 task.stack: ffff000008068000 > PC is at armada_37xx_pinctrl_probe+0x5f8/0x670 > LR is at armada_37xx_pinctrl_probe+0x5e8/0x670 > pc : [] lr : [] pstate: 60000045 > sp : ffff00000806bb80 > x29: ffff00000806bb80 x28: 0000000000000024 > x27: 000000000000000c x26: 0000000000000001 > x25: ffff80001efee760 x24: 0000000000000000 > x23: ffff80001db6f570 x22: ffff80001db6f438 > x21: 0000000000000000 x20: ffff80001d9f4810 > x19: ffff80001db6f418 x18: 0000000000000000 > x17: 0000000000000001 x16: 0000000000000019 > x15: ffffffffffffffff x14: 0140000000000000 > x13: 0000000000000000 x12: 0000000000000030 > x11: 0101010101010101 x10: 0000000000000040 > x9 : ffff000009923580 x8 : ffff80001d400248 > x7 : ffff80001d400270 x6 : 0000000000000000 > x5 : ffff80001d400248 x4 : ffff80001d400270 > x3 : 0000000000000000 x2 : 0000000000000001 > x1 : 0000000000000001 x0 : 0000000000000000 > Process swapper/0 (pid: 1, stack limit = 0xffff000008068000) > Call trace: > Exception stack(0xffff00000806ba40 to 0xffff00000806bb80) > ba40: 0000000000000000 0000000000000001 0000000000000001 0000000000000000 > ba60: ffff80001d400270 ffff80001d400248 0000000000000000 ffff80001d400270 > ba80: ffff80001d400248 ffff000009923580 0000000000000040 0101010101010101 > baa0: 0000000000000030 0000000000000000 0140000000000000 ffffffffffffffff > bac0: 0000000000000019 0000000000000001 0000000000000000 ffff80001db6f418 > bae0: ffff80001d9f4810 0000000000000000 ffff80001db6f438 ffff80001db6f570 > bb00: 0000000000000000 ffff80001efee760 0000000000000001 000000000000000c > bb20: 0000000000000024 ffff00000806bb80 ffff000008e25ccc ffff00000806bb80 > bb40: ffff000008e25cdc 0000000060000045 ffff00000806bb60 ffff0000081189b8 > bb60: ffffffffffffffff ffff00000811cf1c ffff00000806bb80 ffff000008e25cdc > [] armada_37xx_pinctrl_probe+0x5f8/0x670 > [] platform_drv_probe+0x58/0xb8 > [] driver_probe_device+0x22c/0x2d8 > [] __driver_attach+0xbc/0xc0 > [] bus_for_each_dev+0x4c/0x98 > [] driver_attach+0x20/0x28 > [] bus_add_driver+0x1b8/0x228 > [] driver_register+0x60/0xf8 > [] __platform_driver_probe+0x74/0x130 > [] armada_37xx_pinctrl_driver_init+0x20/0x28 > [] do_one_initcall+0x38/0x128 > [] kernel_init_freeable+0x188/0x22c > [] kernel_init+0x10/0x100 > [] ret_from_fork+0x10/0x18 > Code: f9403fa2 12001341 1100075a 9ac12041 (b9000001) > ---[ end trace 8b0f4e05e1603208 ]--- > > This patch moves the initialization of the mask field in the irq_startup > function. However some callbacks such as irq_set_type and irq_set_wake > could be called before irq_startup. For those functions the mask is > computed at each call which is not a issue as these functions are not > located in a hot path but are used sporadically for configuration. > > Fixes: dc749a09ea5e ("gpiolib: allow gpio irqchip to map irqs > dynamically") > Cc: > Signed-off-by: Gregory CLEMENT Patch applied for fixes. Yours, Linus Walleij