From patchwork Fri Dec 2 05:08:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masayoshi Mizuma X-Patchwork-Id: 9457851 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1B9DD60756 for ; Fri, 2 Dec 2016 05:09:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 129512841A for ; Fri, 2 Dec 2016 05:09:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0771B284ED; Fri, 2 Dec 2016 05:09:49 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99695284E9 for ; Fri, 2 Dec 2016 05:09:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752767AbcLBFJr (ORCPT ); Fri, 2 Dec 2016 00:09:47 -0500 Received: from mgwym03.jp.fujitsu.com ([211.128.242.42]:64215 "EHLO mgwym03.jp.fujitsu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751678AbcLBFJr (ORCPT ); Fri, 2 Dec 2016 00:09:47 -0500 Received: from yt-mxoi1.gw.nic.fujitsu.com (unknown [192.168.229.67]) by mgwym03.jp.fujitsu.com with smtp id 164e_69b0_bf40bc22_49b8_4131_9542_fca059e5d247; Fri, 02 Dec 2016 14:09:40 +0900 Received: from g01jpfmpwyt02.exch.g01.fujitsu.local (g01jpfmpwyt02.exch.g01.fujitsu.local [10.128.193.56]) by yt-mxoi1.gw.nic.fujitsu.com (Postfix) with ESMTP id 54F7EAC0180 for ; Fri, 2 Dec 2016 14:09:40 +0900 (JST) Received: from G01JPEXCHYT18.g01.fujitsu.local (G01JPEXCHYT18.g01.fujitsu.local [10.128.194.57]) by g01jpfmpwyt02.exch.g01.fujitsu.local (Postfix) with ESMTP id B675A584304; Fri, 2 Dec 2016 14:08:34 +0900 (JST) Received: from [10.124.101.104] (10.124.101.104) by G01JPEXCHYT18.g01.fujitsu.local (10.128.194.57) with Microsoft SMTP Server id 14.3.266.1; Fri, 2 Dec 2016 14:08:34 +0900 Message-ID: <584101D2.4090200@jp.fujitsu.com> Date: Fri, 2 Dec 2016 14:08:34 +0900 From: Masayoshi Mizuma User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: Jens Axboe CC: , Subject: [PATCH v2] block: avoid incorrect bdi_unregiter call X-SecurityPolicyCheck-GC: OK by FENCE-Mail X-TM-AS-MML: disable Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP bdi_unregister() should be called after bdi_register() is called, so we should check whether WB_registered flag is set. For example of the situation, error path in device driver may call blk_cleanup_queue() before the driver calls bdi_register(). Signed-off-by: Masayoshi Mizuma --- mm/backing-dev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 8fde443..f8b07d4 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -853,6 +853,9 @@ static void bdi_remove_from_list(struct backing_dev_info *bdi) void bdi_unregister(struct backing_dev_info *bdi) { + if (!test_bit(WB_registered, &bdi->wb.state)) + return; + /* make sure nobody finds us on the bdi_list anymore */ bdi_remove_from_list(bdi); wb_shutdown(&bdi->wb);