diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index fd97730479d8640f9c1dabebd4745e7d0e56f20a..c72f5576e4da013dacb14221e44e620480ab6e3d 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -1741,8 +1741,10 @@ static void cache_set_flush(struct closure *cl) if (!IS_ERR_OR_NULL(c->gc_thread)) kthread_stop(c->gc_thread); - if (!IS_ERR(c->root)) - list_add(&c->root->list, &c->btree_cache); + if (!IS_ERR_OR_NULL(c->root)) { + if (!list_empty(&c->root->list)) + list_add(&c->root->list, &c->btree_cache); + } /* * Avoid flushing cached nodes if cache set is retiring