Skip to contentSkip to conversation

block: avoid incorrect bdi_unregiter call

PATCH In review Masayoshi Mizuma 1 participant 2 messages Dec 2, 2016 – Dec 16, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 block: avoid incorrect bdi_unregiter call

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().

---
 mm/backing-dev.c | 3 +++
 1 file changed, 3 insertions(+)
mm/backing-dev.c +3 -0
index 8fde443..f8b07d4 100644
@@ -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);
Signature · 1 line
1.8.3.1
#1 lore raw

Hi Jens,

Could you add this patch for 4.10?

- Masayoshi Mizuma

Quoted 26 lines · On Fri, 2 Dec 2016 14:08:34 +0900 Masayoshi Mizuma wrote:

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().

---
  mm/backing-dev.c | 3 +++
  1 file changed, 3 insertions(+)
mm/backing-dev.c +3 -0
index 8fde443..f8b07d4 100644
@@ -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);