Skip to contentSkip to conversation

master - [device/bcache] fix bug in _alloc_block

PATCH David Teigland 1 participant 1 message Apr 23, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=19647d1cd44d029a8aa2f7e74dbdbd1f114a8c08
Commit:        19647d1cd44d029a8aa2f7e74dbdbd1f114a8c08
Parent:        1563b936911d26c665b590f200884c9ed31ab7c3
Author:        Joe Thornber <[email protected]>
AuthorDate:    Fri Feb 2 14:34:45 2018 +0000
Committer:     David Teigland <[email protected]>
CommitterDate: Fri Apr 20 11:12:50 2018 -0500

[device/bcache] fix bug in _alloc_block

---
 lib/device/bcache.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
lib/device/bcache.c +4 -2
index 4283ce5..e5d0e1b 100644
@@ -449,8 +449,10 @@ static void _exit_free_list(struct bcache *cache)
 
 static struct block *_alloc_block(struct bcache *cache)
 {
-	struct block *b = dm_list_struct_base(_list_pop(&cache->free), struct block, list);
-	return b;
+	if (dm_list_empty(&cache->free))
+		return NULL;
+
+	return dm_list_struct_base(_list_pop(&cache->free), struct block, list);
 }
 
 /*----------------------------------------------------------------