[PATCH v2] block: avoid incorrect bdi_unregiter call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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 from this list: send the line "unsubscribe linux-block" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux