From 3e74542b5da7c60ac3998be377b34bda9c42e6ab Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 13 Feb 2012 11:16:42 +0000 Subject: [PATCH] Add check for allocation failure --- WHATS_NEW | 1 + lib/filters/filter-regex.c | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 6cd2e4d77..e6a559cb2 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.92 - ==================================== + Add check for allocation failure in _build_matcher(). Add check for rimage name allocation failure in _raid_add_images(). Add check for mda_copy failure in _text_pv_setup(). Add check for _mirrored_init_target failure. diff --git a/lib/filters/filter-regex.c b/lib/filters/filter-regex.c index 1b460312d..322119513 100644 --- a/lib/filters/filter-regex.c +++ b/lib/filters/filter-regex.c @@ -110,16 +110,17 @@ static int _build_matcher(struct rfilter *rf, const struct dm_config_value *val) count++; } - /* - * allocate space for them - */ - if (!(regex = dm_pool_alloc(scratch, sizeof(*regex) * count))) - goto_out; + /* Allocate space for them */ + if (!(regex = dm_pool_alloc(scratch, sizeof(*regex) * count))) { + log_error("Failed to allocate regex."); + goto out; + } - /* - * create the accept/reject bitset - */ - rf->accept = dm_bitset_create(rf->mem, count); + /* Create the accept/reject bitset */ + if (!(rf->accept = dm_bitset_create(rf->mem, count))) { + log_error("Failed to create bitset."); + goto out; + } /* * fill the array back to front because we -- 2.43.5