From 9f2961f259ff990d3a21e8edac5f7caa564b0e2e Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 20 Nov 2014 16:35:46 +0100 Subject: [PATCH] cache: check for internal error Don't try to duplicate NULL on internal error path. --- lib/metadata/lv.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c index bf2d04e79..fb1cd7823 100644 --- a/lib/metadata/lv.c +++ b/lib/metadata/lv.c @@ -130,7 +130,12 @@ char *lvseg_discards_dup(struct dm_pool *mem, const struct lv_segment *seg) char *lvseg_cachemode_dup(struct dm_pool *mem, const struct lv_segment *seg) { - return dm_pool_strdup(mem, get_cache_pool_cachemode_name(seg)); + const char *name = get_cache_pool_cachemode_name(seg); + + if (!name) + return_NULL; + + return dm_pool_strdup(mem, name); } #ifdef DMEVENTD