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: 10661205 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 CCB5C15E9 for ; Tue, 30 Oct 2018 16:05:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8D5B2A710 for ; Tue, 30 Oct 2018 16:05:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD7562A77F; Tue, 30 Oct 2018 16:05: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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3F4942A710 for ; Tue, 30 Oct 2018 16:05:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=gqOrKGLmFtEQ89inWTjfcWo67+blv6RdnxEzzHJz+XM=; b=f/9Oqcfqn+Rs4R 8OJ/XLuFjKgWGoQ/D7MqITtzzaW7xqltGt2d80WiNhlXJIHvmvlRtjo20tSRm+70dtg8748IkQjr6 itttrxKiBINHXz/KrW1QLmVIXpqc9qn2UxZT4P7Fllacoy1rgNTnk9Q2FMDD0vVV84xv9Ebx7yBv5 s7VT4Qwzd48ljr7hxl/z6qxkG09IGJBsPTkPhkqFBDf2gXBUvD1l8Y/Xx/+3l0tb9V9Afba41fy7V xFAKpC2DIzT0bmlSpOGYNGRm5aEHPXJiMsSFf64agX/lNEILxOnsvT2Qt3mOqQv3ORcREx1pXtmPf F/CvDUFUCmehcXILt41A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHWWN-0004Y7-Aw; Tue, 30 Oct 2018 16:05:35 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHVmf-0005tl-7I for linux-arm-kernel@bombadil.infradead.org; Tue, 30 Oct 2018 15:18:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=WJ322NJYt3KCJHxHGLXAnFMT7Facd4rpzlJUcFGlM1E=; b=n4TSTg3566OEIUvKqwEy+JISsT mvgoVAgo34L005+PLmVp3kPpFBKoh1tGv2pqkVYgfB6N9ecGXdzCW37maLpnXJIFRqEWpy8vUf629 FKJPuwbqla6RDoGllxR5KW8xdX1EwR1jw15Sw0BUT5exVu3Jl993a9OLhFLLF7iQkBbOkt6DJbpVh b6Fod0Gb5JJ2bgR38dZX6relpE+Tl4hnajp57ZS11DDuVuNE8GvnpM3sNp/GvzNBJH13Z6yqO2GfZ I6C2dFCUBEWuxUVrHPNzS/DOTet7eQXX5cVuTeMEOVPIOXdR9ea9R13ATNWQVb4UqtV3ImcvuQVZ5 cbfAnpqQ==; Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHSfg-0002yF-1e for linux-arm-kernel@lists.infradead.org; Tue, 30 Oct 2018 11:58:57 +0000 Received: by mail-lj1-x242.google.com with SMTP id x85-v6so6846135ljb.2 for ; Tue, 30 Oct 2018 04:58:45 -0700 (PDT) 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-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WJ322NJYt3KCJHxHGLXAnFMT7Facd4rpzlJUcFGlM1E=; b=rTEzTI3cFKwvfODbtJA0HeJdW3OELJgAYE1St0tKnE5NqiLdxKDEv9L+SkV2H5+efy m++r6UtN+9kT1VCJQwbkbToxTl9T3Lw9C5GmYJcx5XiUwu8HDVKaaox6TRTEnFrIO/fR Urs4jEzabnYZyIIkaDtfZPXlzVsZpqhga4Qd4Cc2MblvoRuEmVMdpFN+0vQGAW0G1794 C9mdYcizNMghsCRfosWMQbJSmQbNHCSfC3FApHT8NelTbNWOPO/X4VOJ1gCMXQquqxNV GS9KIALGA0tf5JuZgDBWpAPvbdHO2djdKX7q3JuLwDd5w50YVK8CYUCNO8zn7D4tM0tV luNw== X-Gm-Message-State: AGRZ1gILp5tcL7NFNjN0Trb6VlRo4hhJ6Kdk/byM+Cw+enNW+BJs47am op4ri4QkZfH78jg27zeTqhvUMB+ngchzrg== 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 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181030_115856_097067_E15D8E97 X-CRM114-Status: GOOD ( 15.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anders Roxell , Arnd Bergmann , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-serial@vger.kernel.org, tj@kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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: 10661115 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 86FCD15E9 for ; Tue, 30 Oct 2018 15:43:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 767072A700 for ; Tue, 30 Oct 2018 15:43:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A8A42A87C; Tue, 30 Oct 2018 15:43:09 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3CBB82A874 for ; Tue, 30 Oct 2018 15:43:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=img+Oy9HHcVgP2U9LvCzujPQrd+HY/H39/zWOo40OGw=; b=uWpC9zlfit322p bVcydnHnHwUqnQSA7ZbkRoLHvHnykKgZS9/gI315S+7dJlxua2ztyEq2FOIXj3Q1gDwvelWEj2yoQ k6JQYCQSSoAK0HvjqOtWV3JsAHpxfrYQFc/folMvQZ00sag3Mvgb5XXYu8FONZBRJ4uejsNX98ODn /chuf06bsINkD0ThN2G9ztqYy5TJXFYFIUbqLmiCYPWxUiFvMJBA+gRaL3AUO4dxMrIUYzSvAg/W7 rqZ7aKg9Ee/yoqSfizv36lj8r4WnEESJG+mVLwgl7z1up+hV7F3lm7E4fBnmWqJ1GHYOPoGY1r1i1 KdK51DVleH5iYq3aHfZQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHWAV-0000L8-Do; Tue, 30 Oct 2018 15:42:59 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHVhg-0000kr-5M for linux-arm-kernel@bombadil.infradead.org; Tue, 30 Oct 2018 15:13:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=0c4qq4Ww0v5TJSITOLozxcLN7WvXMS6Pv+NS1rx0eYU=; b=i1975IBGYv/RgPooZRVH+tIEwq PT+3YYSwKsIfSsyIqDRPyL1LvBPV97GWkpzME6EJXKvhnA8/QsdHfTCTnqtjL12oTLnKxHEyEhJBM Xzg4iajlsPOCRIBEeE6/PxCc7q4auUGkCSeHK9bRGrNQs/MnlPjSlsrI85fZUpmbeljuVOnFuJfMi yun04BMQ1bH6qBNGKm1Er/Rna9QqGQs8OweVzVk6CB+DO9v69SjEMXcnImotjx7HODOFeqTBdyS60 s3WMLXDMFdUaM4hTV1EihfddnarnLlrhY4wpBA5FhKLAJZBz/xCAct2pcVpAM3zCOBx0v5umHX/Hj KyHlW3ng==; Received: from mail-lf1-x143.google.com ([2a00:1450:4864:20::143]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHV42-0003aw-AJ for linux-arm-kernel@lists.infradead.org; Tue, 30 Oct 2018 14:32:20 +0000 Received: by mail-lf1-x143.google.com with SMTP id m18-v6so9029200lfl.11 for ; Tue, 30 Oct 2018 07:32:01 -0700 (PDT) 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-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0c4qq4Ww0v5TJSITOLozxcLN7WvXMS6Pv+NS1rx0eYU=; b=m7o2MvhNToEhRqfQqGNTAKbzFzrJPA8snRV7NHpHnolrESyrmgThahmmuANO3i5fDa kv5oudIa6/lUDP/0qJfmORdZiQ3OwTry7OkSdMUAZGEK6iOa7NxVsQMUSDMmEKkODnJh U+r+ZjofNrRYcT1X9O3XCZp7w+tuxJYeectTkh4pS1EIPn/yS8ynkv7jtabgsDmyOTGh Hhg2crzUWXmyMXlRkfKffTuFaPoh6Pq7w7YPnxmeWNPw8weXeQuLiT7AWT/Lu6qjdaBJ CzX/CK/ZctLLabGSO1wYTDfyEGDtxajYrmDkqGU9dE/ua3Mg2R+LA2PKoQCzog0ceGZk OqdA== X-Gm-Message-State: AGRZ1gLx1KhCqyYXNgcauEe2hUGiLcUZ/F0k6s6dcW2GhrgXwttHPhIS 2e+J+lnAAsHd/eK7z8X56HytyZ4q8tMx0w== 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 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181030_103214_539291_73CC80F1 X-CRM114-Status: GOOD ( 14.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anders Roxell , Arnd Bergmann , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-serial@vger.kernel.org, tj@kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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); }