From d70f1127624fa64ee691eb4c9d4bce5a4845f985 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 3 Oct 2016 16:29:55 +0200 Subject: [PATCH] libdm: check for mem when _canonicalize_field_ids Add missing check for dm_pool_strdup() call (Coverity). --- WHATS_NEW_DM | 1 + libdm/libdm-report.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 618673797..4303dc9ef 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.136 - ====================================== + Check mem alloc fail in _canonicalize_field_ids(). Use unsigned math when checking more then 31 legs of raid. Fix 'dmstats delete' with dmsetup older than v1.02.129 Fix stats walk segfault with dmsetup older than v1.02.129 diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c index fed79d472..ebd24391e 100644 --- a/libdm/libdm-report.c +++ b/libdm/libdm-report.c @@ -1228,7 +1228,10 @@ static int _canonicalize_field_ids(struct dm_report *rh) return_0; if (differs) { - canonical_field_dup = dm_pool_strdup(rh->mem, canonical_field); + if (!(canonical_field_dup = dm_pool_strdup(rh->mem, canonical_field))) { + log_error("_canonicalize_field_dup: dm_pool_alloc failed."); + return 0; + } rh->canonical_field_ids[i] = canonical_field_dup; } else rh->canonical_field_ids[i] = rh->fields[i].id;