From 09fa32a423e8ae1600769effa6fec02a2cb98d7a Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Fri, 24 Nov 2017 11:05:51 +0000 Subject: [PATCH] [ft-lib/bcache] alloc_block wasn't checking for an empty free list --- ft-lib/bcache.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ft-lib/bcache.c b/ft-lib/bcache.c index ca1921d..6f3c987 100644 --- a/ft-lib/bcache.c +++ b/ft-lib/bcache.c @@ -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); } /*----------------------------------------------------------------