Skip to content

Commit

Permalink
bcache: fix cache_set_flush() NULL pointer dereference on OOM
Browse files Browse the repository at this point in the history
commit f8b1126 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
  • Loading branch information
Eric Wheeler authored and wtarreau committed Jun 7, 2016
1 parent 7493d12 commit f5b0d85
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/md/bcache/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,9 @@ static void cache_set_flush(struct closure *cl)
set_bit(CACHE_SET_STOPPING_2, &c->flags);
wake_up(&c->alloc_wait);

if (!c)
closure_return(cl);

bch_cache_accounting_destroy(&c->accounting);

kobject_put(&c->internal);
Expand Down

0 comments on commit f5b0d85

Please sign in to comment.