[ft-lib/bcache] alloc_block wasn't checking for an empty free list

This commit is contained in:
Joe Thornber 2017-11-24 11:05:51 +00:00
parent 0569e06e80
commit 09fa32a423
1 changed files with 4 additions and 2 deletions

View File

@ -444,8 +444,10 @@ static void exit_free_list(struct bcache *cache)
static struct block *alloc_block(struct bcache *cache)
{
struct block *b = container_of(list_pop(&cache->free), struct block, list);
return b;
if (list_empty(&cache->free))
return NULL;
return container_of(list_pop(&cache->free), struct block, list);
}
/*----------------------------------------------------------------