Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2400512imu; Thu, 24 Jan 2019 12:07:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN6hejB1/K8Cmfj9OAswi8GpMWmIeriNkY/YZACRM5Jd5lfvMAfWKcrRHHhHubPFuikl9vYC X-Received: by 2002:a17:902:981:: with SMTP id 1mr7737263pln.142.1548360425848; Thu, 24 Jan 2019 12:07:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548360425; cv=none; d=google.com; s=arc-20160816; b=V2qqyMxICrFXT4DyQAzMbpJRVtKhqnXm3Ro+XwNeJ+cqUFcP/NJ+c9nzIAMXLtJphp 3bj/c2qbm4z65LpVob9ZHZTTbR5OEralhGhp4g2/Z9NAhNy9yaeKQqC/9XgnW+1MBFd+ 5YThro6XRPyotVxOEIC0NqQcToYT6O11GaCAp0BCxXe/WTvPyqplbNECQTv+6g5i8wmR 5iv80RIMGhS+ZVKYcjpSKJoO6YGn3cMSwgOw+kbEcVizCx0Uf7UfRcpRlIjfY6P3RC9k oDsXt0IEez6ySGX2JeTgNK1TXi/IyxkkD2+7Ivluk2rqsfWd1qTb0oRDEWvS/X43OzKl 6CMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ITYd0vlY8e/H6l3ZM3z2TRnSI26Oa9MHRKE3UTaLcWE=; b=rXXWdgTkZWVhtT0ARhgbjBAYoS3aEDT5KBEkI8HYHXh7e1q91Jxd/gqP0z6rXRWtOB pgbBH2y1BKow8lDPzv/AFWvaWrPsKS5DkgJYoVj7+UAV/SANAlTnv/r4we03a62USX4u JQhZRfkghH6BNl0AdtdmlMptEUm+8B6ZgnHuOdP58wC9xLXvOx7q2mbrBNgzbWFG6URF MfEGQJ/GeHjUn+pKLtP9u1+E4elHcLaIkJ83rFn4zcFdiJgScdj3x1CTYRQsoetM7fbt YkcREeaCYKvaTK/VFZKwckdrxvYdBaWnZY55vj0vTAEQzvi3HCAfE68koXBMBQW5Stsv GDaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JPnWPPPz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t3si23234047pgl.108.2019.01.24.12.06.50; Thu, 24 Jan 2019 12:07:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JPnWPPPz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728565AbfAXUF1 (ORCPT + 99 others); Thu, 24 Jan 2019 15:05:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:58788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731543AbfAXTbG (ORCPT ); Thu, 24 Jan 2019 14:31:06 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6A863218D4; Thu, 24 Jan 2019 19:31:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548358265; bh=Br3IvZoVYTxmFXo/a6Bzsf/EBvCf7+BhN7UdpFVgIaw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JPnWPPPzsF23EFzY/9YquZXsM2NoLy39vOkJm//2unXdw6x+24DKibZjx5by6Aoqy 5tIfeVyNhStQLXFHJ34fBqo8LZRScd/qeeTnzq+/cbm2g4LETaTFf4sOTTujyoVWNU /USXwmkvc2TVjfuU99PyAw5uyz+KOa9oINtWm1YE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Anders Roxell , Sasha Levin Subject: [PATCH 4.14 12/63] writeback: dont decrement wb->refcnt if !wb->bdi Date: Thu, 24 Jan 2019 20:20:01 +0100 Message-Id: <20190124190156.405237543@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190124190155.176570028@linuxfoundation.org> References: <20190124190155.176570028@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 347a28b586802d09604a149c1a1f6de5dccbe6fa ] 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 Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- 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 3c1beffc861a..19240379637f 100644 --- a/include/linux/backing-dev-defs.h +++ b/include/linux/backing-dev-defs.h @@ -233,6 +233,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); } -- 2.19.1