[PATCH 3.16 102/133] bcache: fix crash on shutdown in passthrough mode

From: Ben Hutchings
Date: Tue Nov 21 2017 - 21:35:54 EST


3.16.51-rc1 review patch. If anyone has any objections, please let me know.

------------------

From: Slava Pestov <sp@xxxxxxxxxxxxx>

commit a664d0f05a2ec02c8f042db536d84d15d6e19e81 upstream.

We never started the writeback thread in this case, so don't stop it.
Signed-off-by: Ben Hutchings <ben@xxxxxxxxxxxxxxx>
---
drivers/md/bcache/super.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1073,7 +1073,8 @@ static void cached_dev_free(struct closu
struct cached_dev *dc = container_of(cl, struct cached_dev, disk.cl);

cancel_delayed_work_sync(&dc->writeback_rate_update);
- kthread_stop(dc->writeback_thread);
+ if (!IS_ERR_OR_NULL(dc->writeback_thread))
+ kthread_stop(dc->writeback_thread);

mutex_lock(&bch_register_lock);