From 69907e0780e0ca5be61d5e5e40d23275937a8c11 Mon Sep 17 00:00:00 2001 From: Marian Csontos Date: Tue, 26 Jun 2018 17:04:18 +0200 Subject: [PATCH] bcache: Fix null pointer dereferencing (cherry picked from commit a14f21bf1ddbb93b13a917cad8720fed6c94d6de) Conflicts: lib/device/bcache.c --- lib/device/bcache.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/device/bcache.c b/lib/device/bcache.c index 3b780474d..c7c19097c 100644 --- a/lib/device/bcache.c +++ b/lib/device/bcache.c @@ -559,11 +559,13 @@ static bool _init_free_list(struct bcache *cache, unsigned count, unsigned pgsiz if (!data) return false; - cache->raw_data = data; cache->raw_blocks = dm_malloc(count * sizeof(*cache->raw_blocks)); - if (!cache->raw_blocks) - dm_free(cache->raw_data); + free(data); + return false; + } + + cache->raw_data = data; for (i = 0; i < count; i++) { struct block *b = cache->raw_blocks + i;