diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 3f858de9e9602fcc0f175a84316b0d96ff5c7f41..10a258f6ce13a6c15798f8ae7e3fa30dc8fd2567 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -1612,8 +1612,13 @@ static void cache_set_flush(struct closure *cl) mutex_unlock(&b->write_lock); } + /* + * If the register_cache_set() call to bch_cache_set_alloc() failed, + * ca has not been assigned a value and return error. + * So we need check ca is not NULL during bch_cache_set_unregister(). + */ for_each_cache(ca, c, i) - if (ca->alloc_thread) + if (ca && ca->alloc_thread) kthread_stop(ca->alloc_thread); if (c->journal.cur) {