linux-bcache.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bcache: fix up kthread_stop crash in cached_dev_free()
@ 2023-04-25 12:56 Mingzhe Zou
  0 siblings, 0 replies; only message in thread
From: Mingzhe Zou @ 2023-04-25 12:56 UTC (permalink / raw)
  To: colyli, bcache, linux-bcache; +Cc: zoumingzhe

In bch_cached_dev_attach(), writeback kthread stopped if
bch_cached_dev_run() returns error. Then, cached_dev_free()
will stop writeback kthread again and crash.

This patch set dc->writeback_thread to null after call kthread_stop().

Fixes: 5c2a634cbfaf ("bcache: stop writeback kthread and kworker when bch_cached_dev_run() failed")
Signed-off-by: Mingzhe Zou <mingzhe.zou@easystack.cn>
---
 drivers/md/bcache/super.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index ba3909bb6bea..7b6e533b0339 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1310,6 +1310,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
 		 * have to be stopped manually here.
 		 */
 		kthread_stop(dc->writeback_thread);
+		dc->writeback_thread = NULL;
 		cancel_writeback_rate_update_dwork(dc);
 		pr_err("Couldn't run cached device %pg\n", dc->bdev);
 		return ret;
-- 
2.17.1.windows.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-25 13:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-25 12:56 [PATCH] bcache: fix up kthread_stop crash in cached_dev_free() Mingzhe Zou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).