From 17802084c90df4ced26ae395292f0fc8466e72b7 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Tue, 9 Mar 2021 19:35:53 +0100 Subject: [PATCH] bcache: fix incorrect pointer check With commit b44db5d1a7ecc2e8e3cef0852c4397b64ddf0a09 needs to check allocated pointer for failed malloc(). Existing check was actually no checking anything so failing malloc here would result in segfault (although with very low chance to ever happen). --- lib/device/bcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/device/bcache.c b/lib/device/bcache.c index a3803befb..a5f2a5a86 100644 --- a/lib/device/bcache.c +++ b/lib/device/bcache.c @@ -74,7 +74,7 @@ static struct cb_set *_cb_set_create(unsigned nr) unsigned i; struct cb_set *cbs = malloc(sizeof(*cbs) + nr * sizeof(*cbs->vec)); - if (!cbs->vec) + if (!cbs) return NULL; dm_list_init(&cbs->free);