All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: <linux-mm@kvack.org>, <linux-block@vger.kernel.org>
Subject: [PATCH v2] block: avoid incorrect bdi_unregiter call
Date: Fri, 2 Dec 2016 14:08:34 +0900	[thread overview]
Message-ID: <584101D2.4090200@jp.fujitsu.com> (raw)

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 <m.mizuma@jp.fujitsu.com>
---
 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);
-- 
1.8.3.1

WARNING: multiple messages have this Message-ID (diff)
From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-mm@kvack.org, linux-block@vger.kernel.org
Subject: [PATCH v2] block: avoid incorrect bdi_unregiter call
Date: Fri, 2 Dec 2016 14:08:34 +0900	[thread overview]
Message-ID: <584101D2.4090200@jp.fujitsu.com> (raw)

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 <m.mizuma@jp.fujitsu.com>
---
 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);
-- 
1.8.3.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2016-12-02  5:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-02  5:08 Masayoshi Mizuma [this message]
2016-12-02  5:08 ` [PATCH v2] block: avoid incorrect bdi_unregiter call Masayoshi Mizuma
2016-12-16  5:00 ` Masayoshi Mizuma
2016-12-16  5:00   ` Masayoshi Mizuma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=584101D2.4090200@jp.fujitsu.com \
    --to=m.mizuma@jp.fujitsu.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.