From 58e3ba19a23b8dd56be880c51300469145382753 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 20 Dec 2010 14:38:22 +0000 Subject: [PATCH] Add missing test for reallocation error. --- WHATS_NEW | 1 + lib/metadata/lv_manip.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/WHATS_NEW b/WHATS_NEW index 03859a5ec..5e705f7d6 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.79 - =================================== + Add missing test for reallocation error in _find_parallel_space(). Add check for unlink error result in remove_lockfile() (dmeventd). Use dm_free for dm_malloc-ed areas in _clog_ctr/_clog_dtr (cmirrord). Add checks for allocation errors in config node clonning. diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index ee8e9317a..4a984a598 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -1302,7 +1302,12 @@ static int _find_parallel_space(struct alloc_handle *ah, alloc_policy_t alloc, /* Expand areas array if needed after an area was split. */ if (ix + ix_offset > *areas_size_ptr) { *areas_size_ptr *= 2; - *areas_ptr = dm_realloc(*areas_ptr, sizeof(**areas_ptr) * (*areas_size_ptr)); + if (!(*areas_ptr = dm_realloc(*areas_ptr, + sizeof(**areas_ptr) * + (*areas_size_ptr)))) { + log_error("Memory reallocation for parallel areas failed."); + return 0; + } } (*areas_ptr)[ix + ix_offset - 1].pva = pva; (*areas_ptr)[ix + ix_offset - 1].used = required;