Skip to content

Commit f8b1126

Browse files
Eric Wheeleraxboe
authored andcommitted
bcache: fix cache_set_flush() NULL pointer dereference on OOM
When bch_cache_set_alloc() fails to kzalloc the cache_set, the asyncronous closure handling tries to dereference a cache_set that hadn't yet been allocated inside of cache_set_flush() which is called by __cache_set_unregister() during cleanup. This appears to happen only during an OOM condition on bcache_register. Signed-off-by: Eric Wheeler <bcache@linux.ewheeler.net> Cc: stable@vger.kernel.org
1 parent 9b29972 commit f8b1126

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/md/bcache/super.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,6 +1373,9 @@ static void cache_set_flush(struct closure *cl)
13731373
struct btree *b;
13741374
unsigned i;
13751375

1376+
if (!c)
1377+
closure_return(cl);
1378+
13761379
bch_cache_accounting_destroy(&c->accounting);
13771380

13781381
kobject_put(&c->internal);

0 commit comments

Comments
 (0)