From patchwork Tue Oct 30 11:35:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 10660719 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2F6FD1932 for ; Tue, 30 Oct 2018 11:36:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F42E28501 for ; Tue, 30 Oct 2018 11:36:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13538299EE; Tue, 30 Oct 2018 11:36:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7248228501 for ; Tue, 30 Oct 2018 11:36:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BCB8E6B0284; Tue, 30 Oct 2018 07:36:13 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B79FF6B0371; Tue, 30 Oct 2018 07:36:13 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A68B06B03C1; Tue, 30 Oct 2018 07:36:13 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by kanga.kvack.org (Postfix) with ESMTP id 399A86B0284 for ; Tue, 30 Oct 2018 07:36:13 -0400 (EDT) Received: by mail-lf1-f69.google.com with SMTP id m3-v6so1673154lfh.14 for ; Tue, 30 Oct 2018 04:36:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:mime-version:content-transfer-encoding; bh=WJ322NJYt3KCJHxHGLXAnFMT7Facd4rpzlJUcFGlM1E=; b=MvbkFp4nEjt6hb5oUItpAp18GtDxPI0RhbnOc9+XHJW/sYXEVtl2+5GT4S7BacnC36 wpgex0XUiZRFyZgLLxEQ0m/AXQRCD7qbxwkSu1nA5z7KfE2+zKbAlXPTwrD8FsKFEYRP N+Pp1VKYYV9j6Dq36sWlDYcxPkBbW/lCzxb71csxlNpE0LkOFP2c1G7fuM1NiPTZXLp6 rSM67+19vKUPDSx81fWojiQW5p3ivkyfV5B/sorNvToWMP+5DuP/xMpsTEIdMwAPqPqk Ikwa9JIDGYy/feTIoXyycZf9KXzVVHchc6qXaFEik4fDpa1wVNwhVYdlcpM6DAjlGoNf 9qLQ== X-Gm-Message-State: AGRZ1gJeRk9ZnOPn3G07MgBpOAdyJUW3Po8fyGZ1Za5Z7ZuDg0NWztXw iqINE07fv7MFoplVHk519K2SlgGPnbx48K/9Vzwl+GMs/A2i4XDDHmPVUKMwee6fwUPGR1QKV5F YszbT0cHGyZycZUdlTDK/HXuz84yms52jwRU0J/uAs6U8r7UACcCOKIQ5Xt3bX9xKn4tqTSp3md 3B0bhdTU7crmlXj/7ccuJ4GcMJGG/Tn8RnNOeX1ngnykidOgiVP3aopCFeDQrnjcvj0IoGaD9Sk GQ6GDrLi2kIV/2sXWDYQWB0pCcrYl3itzX2Mxyi4e8bSjMVh7FpfXiokTETLz9nbx7sOeLL4sKZ fpBs9mLdb7dupNwJ+g5oykzcTdNw0Scq2PdnxUDYBmXnEUYWg8nI+j7gujwmV4G5Grp0moXaJsl T X-Received: by 2002:a19:e601:: with SMTP id d1mr1727937lfh.71.1540899372199; Tue, 30 Oct 2018 04:36:12 -0700 (PDT) X-Received: by 2002:a19:e601:: with SMTP id d1mr1727853lfh.71.1540899370314; Tue, 30 Oct 2018 04:36:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540899370; cv=none; d=google.com; s=arc-20160816; b=1HRG3hxsQFH8y9zYIymhaWBeNAwVNq1IZ0TjNo1k5U9nhOyXewzKmfbnzlEnPOCv68 eWIxxVefOX8nJXIdhE/J1nnoFBM/FW3uvnvrqasU9GgIOrOcizR3kxS1mIF6LZrqpb5I VBwKA1YgdCD+SnIoPf+yrX7pbEFVM5yZg3cSfeVyCvvM7kHqhEhuw/Y9GRxSKm9d7A98 VqUUB7Pbnms/gB1OM2hq481CIaW2VoMLw+4otd5lLNvCWqfBXAH+uMT3cmNhO8NO33F+ xtREPk7WqSAF1RQPSA4LMLmkHGm5yX/1Z+6a1l4/UclZBEz4ecVGGHp7Rlx6b6trdoO4 76Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=WJ322NJYt3KCJHxHGLXAnFMT7Facd4rpzlJUcFGlM1E=; b=aY1h250eVMLz0ZQ8JS6U+LbWGvkvdFKW3MTHVB8mVS5eRovMXrvVn/2aRJbVkGMpRe 3fmuaefL9tT8ROdko54yDVUirbx12ukYKEag4++eBpQsbrLC43KlZwoh9G2pof9tTulB HBvLg5DfnwA/FKdcH3lgWM8asPNKlv4WlJaWPx9fRqrpM4zESFH94ExEI2978Cgrd+5c zOUEw/+TWECrbN76JK19fXFyU7udid1/NUlJhQr4gUm0RPtK0p2mgXn4V++7wc6b8Gxt 3+iWyL3T+R5EEZnmrifG3lQ+NrvwVdniLLLXw2S5w+LscbQuMiyVP7khZsYDrUzma9d8 ovGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="C/OUWmrn"; spf=pass (google.com: domain of anders.roxell@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=anders.roxell@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id z12-v6sor14175738ljb.6.2018.10.30.04.36.09 for (Google Transport Security); Tue, 30 Oct 2018 04:36:10 -0700 (PDT) Received-SPF: pass (google.com: domain of anders.roxell@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="C/OUWmrn"; spf=pass (google.com: domain of anders.roxell@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=anders.roxell@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WJ322NJYt3KCJHxHGLXAnFMT7Facd4rpzlJUcFGlM1E=; b=C/OUWmrnUZt9mtLdmhmsRuamkFh85fCNtkCGoAceZK69kQSs2tpzHQ8Byj1qcs5Dwx CKFy2OQtqFOVXkLZ79CujISmdp+wDkLIeik+Zp+jlcnNi1BQnh7Bfe/oDYaipE4cxXW+ dtxQG2vqofahYzB+Jqmo+3Alh6BPc6PGAU7I4= X-Google-Smtp-Source: AJdET5fixOHKZYR+TvRd6LZ5gJyi0XnVjjuyXT2I/Gcj0MJTw+xpgoSpRqVVblDkfVtBmQK2r1EcXA== X-Received: by 2002:a2e:7011:: with SMTP id l17-v6mr1528361ljc.147.1540899369006; Tue, 30 Oct 2018 04:36:09 -0700 (PDT) Received: from localhost (c-732171d5.07-21-73746f28.bbcust.telenor.se. [213.113.33.115]) by smtp.gmail.com with ESMTPSA id j66-v6sm3749434ljb.45.2018.10.30.04.36.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Oct 2018 04:36:08 -0700 (PDT) From: Anders Roxell To: linux@armlinux.org.uk, gregkh@linuxfoundation.org, akpm@linux-foundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, tj@kernel.org, Anders Roxell , Arnd Bergmann Subject: [PATCH v2 1/2] serial: set suppress_bind_attrs flag only if builtin Date: Tue, 30 Oct 2018 12:35:44 +0100 Message-Id: <20181030113545.30999-1-anders.roxell@linaro.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP When the test 'CONFIG_DEBUG_TEST_DRIVER_REMOVE=y' is enabled, arch_initcall(pl011_init) came before subsys_initcall(default_bdi_init). devtmpfs gets killed because we try to remove a file and decrement the wb reference count before the noop_backing_device_info gets initialized. [ 0.332075] Serial: AMBA PL011 UART driver [ 0.485276] 9000000.pl011: ttyAMA0 at MMIO 0x9000000 (irq = 39, base_baud = 0) is a PL011 rev1 [ 0.502382] console [ttyAMA0] enabled [ 0.515710] Unable to handle kernel paging request at virtual address 0000800074c12000 [ 0.516053] Mem abort info: [ 0.516222] ESR = 0x96000004 [ 0.516417] Exception class = DABT (current EL), IL = 32 bits [ 0.516641] SET = 0, FnV = 0 [ 0.516826] EA = 0, S1PTW = 0 [ 0.516984] Data abort info: [ 0.517149] ISV = 0, ISS = 0x00000004 [ 0.517339] CM = 0, WnR = 0 [ 0.517553] [0000800074c12000] user address but active_mm is swapper [ 0.517928] Internal error: Oops: 96000004 [#1] PREEMPT SMP [ 0.518305] Modules linked in: [ 0.518839] CPU: 0 PID: 13 Comm: kdevtmpfs Not tainted 4.19.0-rc5-next-20180928-00002-g2ba39ab0cd01-dirty #82 [ 0.519307] Hardware name: linux,dummy-virt (DT) [ 0.519681] pstate: 80000005 (Nzcv daif -PAN -UAO) [ 0.519959] pc : __destroy_inode+0x94/0x2a8 [ 0.520212] lr : __destroy_inode+0x78/0x2a8 [ 0.520401] sp : ffff0000098c3b20 [ 0.520590] x29: ffff0000098c3b20 x28: 00000000087a3714 [ 0.520904] x27: 0000000000002000 x26: 0000000000002000 [ 0.521179] x25: ffff000009583000 x24: 0000000000000000 [ 0.521467] x23: ffff80007bb52000 x22: ffff80007bbaa7c0 [ 0.521737] x21: ffff0000093f9338 x20: 0000000000000000 [ 0.522033] x19: ffff80007bbb05d8 x18: 0000000000000400 [ 0.522376] x17: 0000000000000000 x16: 0000000000000000 [ 0.522727] x15: 0000000000000400 x14: 0000000000000400 [ 0.523068] x13: 0000000000000001 x12: 0000000000000001 [ 0.523421] x11: 0000000000000000 x10: 0000000000000970 [ 0.523749] x9 : ffff0000098c3a60 x8 : ffff80007bbab190 [ 0.524017] x7 : ffff80007bbaa880 x6 : 0000000000000c88 [ 0.524305] x5 : ffff0000093d96c8 x4 : 61c8864680b583eb [ 0.524567] x3 : ffff0000093d6180 x2 : ffffffffffffffff [ 0.524872] x1 : 0000800074c12000 x0 : 0000800074c12000 [ 0.525207] Process kdevtmpfs (pid: 13, stack limit = 0x(____ptrval____)) [ 0.525529] Call trace: [ 0.525806] __destroy_inode+0x94/0x2a8 [ 0.526108] destroy_inode+0x34/0x88 [ 0.526370] evict+0x144/0x1c8 [ 0.526636] iput+0x184/0x230 [ 0.526871] dentry_unlink_inode+0x118/0x130 [ 0.527152] d_delete+0xd8/0xe0 [ 0.527420] vfs_unlink+0x240/0x270 [ 0.527665] handle_remove+0x1d8/0x330 [ 0.527875] devtmpfsd+0x138/0x1c8 [ 0.528085] kthread+0x14c/0x158 [ 0.528291] ret_from_fork+0x10/0x18 [ 0.528720] Code: 92800002 aa1403e0 d538d081 8b010000 (c85f7c04) [ 0.529367] ---[ end trace 5a3dee47727f877c ]--- Rework to set suppress_bind_attrs flag to avoid removing the device when CONFIG_DEBUG_TEST_DRIVER_REMOVE=y. This applies for pic32_uart and xilinx_uartps as well. Co-developed-by: Arnd Bergmann Signed-off-by: Arnd Bergmann Signed-off-by: Anders Roxell --- drivers/tty/serial/amba-pl011.c | 2 ++ drivers/tty/serial/pic32_uart.c | 1 + drivers/tty/serial/xilinx_uartps.c | 1 + 3 files changed, 4 insertions(+) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index ebd33c0232e6..89ade213a1a9 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -2780,6 +2780,7 @@ static struct platform_driver arm_sbsa_uart_platform_driver = { .name = "sbsa-uart", .of_match_table = of_match_ptr(sbsa_uart_of_match), .acpi_match_table = ACPI_PTR(sbsa_uart_acpi_match), + .suppress_bind_attrs = IS_BUILTIN(CONFIG_SERIAL_AMBA_PL011), }, }; @@ -2808,6 +2809,7 @@ static struct amba_driver pl011_driver = { .drv = { .name = "uart-pl011", .pm = &pl011_dev_pm_ops, + .suppress_bind_attrs = IS_BUILTIN(CONFIG_SERIAL_AMBA_PL011), }, .id_table = pl011_ids, .probe = pl011_probe, diff --git a/drivers/tty/serial/pic32_uart.c b/drivers/tty/serial/pic32_uart.c index fd80d999308d..0bdf1687983f 100644 --- a/drivers/tty/serial/pic32_uart.c +++ b/drivers/tty/serial/pic32_uart.c @@ -919,6 +919,7 @@ static struct platform_driver pic32_uart_platform_driver = { .driver = { .name = PIC32_DEV_NAME, .of_match_table = of_match_ptr(pic32_serial_dt_ids), + .suppress_bind_attrs = IS_BUILTIN(CONFIG_SERIAL_PIC32), }, }; diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 57c66d2c3471..379242b96790 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1719,6 +1719,7 @@ static struct platform_driver cdns_uart_platform_driver = { .name = CDNS_UART_NAME, .of_match_table = cdns_uart_of_match, .pm = &cdns_uart_dev_pm_ops, + .suppress_bind_attrs = IS_BUILTIN(CONFIG_SERIAL_XILINX_PS_UART), }, }; From patchwork Tue Oct 30 11:35:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 10660721 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB5AC1932 for ; Tue, 30 Oct 2018 11:36:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8B3128501 for ; Tue, 30 Oct 2018 11:36:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C0EA299EE; Tue, 30 Oct 2018 11:36:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30FFA28501 for ; Tue, 30 Oct 2018 11:36:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5FCE66B0494; Tue, 30 Oct 2018 07:36:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5AD656B0498; Tue, 30 Oct 2018 07:36:36 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49E3F6B0499; Tue, 30 Oct 2018 07:36:36 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by kanga.kvack.org (Postfix) with ESMTP id D1B566B0494 for ; Tue, 30 Oct 2018 07:36:35 -0400 (EDT) Received: by mail-lj1-f197.google.com with SMTP id e11-v6so4201741lji.23 for ; Tue, 30 Oct 2018 04:36:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0c4qq4Ww0v5TJSITOLozxcLN7WvXMS6Pv+NS1rx0eYU=; b=jqcTT++PD2it/9tRqTmuCWTrAXlDiRNQkkHoFcxQK5pTGG+sy1no+AGbeBA44rvJsg semOz9RDdBW/l5Isdr4+wPuG+L1wE+n7i0kqUrk3Ib6xhfzAfCeP/puXYqfGsn37eXeI z2I1mZ+TKWt1PseZWcxUfj7i5x2LgHM+FQ+4Cz3m1GyyWkjVhBuk9ZjvsHelYhvW7k2v uO3iTBVm8yWPzyWoj3YzZkA4DMd244B5PD8l53pdYGah6sElmcKGhm76yknlUJV4KCu5 Q4QKZBsR3q39db9eoIdRdS9ZIWdugd30/gfMa2P1at0pkmnyCZv8oPZGmpPSGveGrXWA 4EGw== X-Gm-Message-State: AGRZ1gIFf33F9h75k2BmspcGBDCfzlbVW+o0/hvnyxfMIUQe7W9hBxel S63AUzOqDfAXaLT3G+/eObJblrresreddEMhMRimw0wSB/47gaz/98SKBo7JMUmxFx3sUDdTt3A EjRyRaQalBAeiFP7layzkY16I3ElCvxyK1CsxU42AgVbm4BtGbw74e8NPc8GJWZjGr8G9uGQAV6 dWDLW04ahE5HQvdA4DGdfz1CxMotrTbMoy856C3M6tSwjKvSgJuhZweRjTFowes5fuhG5v8i2Jp LvPOU6OO5EiYM3+0rbxQyMIn4bBM4AHcLTaw9zPF+k7EOy4dNtKgcdMII8Ak+XY7EJaGluX7Wn7 /QpN9tsg1Of5DsRvDX4DK9FIylbjtpgRLYjS7JmsZTPSCpGGvWbmJV1ixSiibQlqrbx3iaMp8vK 8 X-Received: by 2002:a2e:2019:: with SMTP id g25-v6mr4056521ljg.20.1540899395137; Tue, 30 Oct 2018 04:36:35 -0700 (PDT) X-Received: by 2002:a2e:2019:: with SMTP id g25-v6mr4056470ljg.20.1540899393890; Tue, 30 Oct 2018 04:36:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540899393; cv=none; d=google.com; s=arc-20160816; b=zJX3tCkQ7eQa4bPaDSWdT5RXo77q4QOKSHgqvSOsFXupxktcQJpCaw2WZPO4WKjjgN DByHTS1HhHnFAd2eQ4ZuwZgsPYa8TzY1OcaOwrvQhDzPV6R3z7bkfgNt0GBIjiUYo+Vu NGbc6aUOZKKspbq76M+OMN77yZxfarrkmavkPtUzT3cKQzwG2lUeflhyf2WfKes7LkKY spvgYq6e3FMLp+zg4A7jqB3Aoi9uXxBstXokLPlW4Jj0sLfPNcUEeyurQsouAPRkskyM 9K9EOlenok/RzjpGLFqCtWbfZoZgqPLm9pF3WuhYMaMKNRZX4Jjhd2NnTQqmbP2ycWg7 8nmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=0c4qq4Ww0v5TJSITOLozxcLN7WvXMS6Pv+NS1rx0eYU=; b=jSvEQzjKF7/2ZcycQnBsOlP2Z+ctwAdbHi6qh1RTMA+uaoNH9ir0jwWF9J5Wlm0Yui imwkMI6p+zGHy1S343kIIJM9wgS+DYCsLgqHSTnFVg0jZ9xidCfF9lsIjVLNrPc6kbeA jxcPW6UeqVWo+ViFbpdTL/3vac+Z3N4CHIdwIVNlITwOpdV+dePFyu5b/JZ9u3A+UYFJ znXFLanXjjnajcsk4AtNt5KB1BSdFM70K1BX7nwQBolurpg1E1Vz6z1y7D0IxxNkp7fJ +nOpQIl6+9g+LzjP8YAGj30P88aIzIWpkg1atmUHZIt5m/VELUMgl40tmy3WaNIZq6Rg 7TVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gOwgddOR; spf=pass (google.com: domain of anders.roxell@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=anders.roxell@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id y206sor3327092lfa.42.2018.10.30.04.36.33 for (Google Transport Security); Tue, 30 Oct 2018 04:36:33 -0700 (PDT) Received-SPF: pass (google.com: domain of anders.roxell@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gOwgddOR; spf=pass (google.com: domain of anders.roxell@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=anders.roxell@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0c4qq4Ww0v5TJSITOLozxcLN7WvXMS6Pv+NS1rx0eYU=; b=gOwgddOR+rM/NtNShdA4L1NNw1ah30l4AEuLYCWkGLxRpGkzqsuwELBEJyXstMxvks r3xIVi8YMesJ+WLA6wEeQtB+6AHhfluoImBdENXlMGxg9GKiRGYsCdFDGvJOiJ6Tlyvn 8coK+mZ5pGtFlOWi8EUhQ4xAw8yLu8MTg5tik= X-Google-Smtp-Source: AJdET5cBHlupzI8DFEfRW+LDvxxFFzuGpyilXSNopOL7zP/54j9IfzjkvZ65UOZv4HAurPUmo0LM8A== X-Received: by 2002:a19:41c4:: with SMTP id o187mr1719486lfa.32.1540899393326; Tue, 30 Oct 2018 04:36:33 -0700 (PDT) Received: from localhost (c-732171d5.07-21-73746f28.bbcust.telenor.se. [213.113.33.115]) by smtp.gmail.com with ESMTPSA id l67-v6sm3776781lfg.45.2018.10.30.04.36.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Oct 2018 04:36:32 -0700 (PDT) From: Anders Roxell To: linux@armlinux.org.uk, gregkh@linuxfoundation.org, akpm@linux-foundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, tj@kernel.org, Anders Roxell , Arnd Bergmann Subject: [PATCH v2 2/2] writeback: don't decrement wb->refcnt if !wb->bdi Date: Tue, 30 Oct 2018 12:35:45 +0100 Message-Id: <20181030113545.30999-2-anders.roxell@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181030113545.30999-1-anders.roxell@linaro.org> References: <20181030113545.30999-1-anders.roxell@linaro.org> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This happened while running in qemu-system-aarch64, the AMBA PL011 UART driver when enabling CONFIG_DEBUG_TEST_DRIVER_REMOVE. arch_initcall(pl011_init) came before subsys_initcall(default_bdi_init), devtmpfs' handle_remove() crashes because the reference count is a NULL pointer only because wb->bdi hasn't been initialized yet. Rework so that wb_put have an extra check if wb->bdi before decrement wb->refcnt and also add a WARN_ON_ONCE to get a warning if it happens again in other drivers. Fixes: 52ebea749aae ("writeback: make backing_dev_info host cgroup-specific bdi_writebacks") Co-developed-by: Arnd Bergmann Signed-off-by: Arnd Bergmann Signed-off-by: Anders Roxell --- include/linux/backing-dev-defs.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h index 9a6bc0951cfa..c31157135598 100644 --- a/include/linux/backing-dev-defs.h +++ b/include/linux/backing-dev-defs.h @@ -258,6 +258,14 @@ static inline void wb_get(struct bdi_writeback *wb) */ static inline void wb_put(struct bdi_writeback *wb) { + if (WARN_ON_ONCE(!wb->bdi)) { + /* + * A driver bug might cause a file to be removed before bdi was + * initialized. + */ + return; + } + if (wb != &wb->bdi->wb) percpu_ref_put(&wb->refcnt); }