From a75b0d4ee6b7cca0038327caa684a5a23d649301 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 1 Mar 2012 21:21:54 +0000 Subject: [PATCH] Check for alloc error Simplify segtype_str usage and check for NULL segtype. --- WHATS_NEW | 1 + tools/lvcreate.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index a5e679303..2e068a816 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.94 - ==================================== + Check for alloc fail from get_segtype_from_string() in _lvcreate_params(). Add _rimage as reserved suffix to lvm.8 man page. Improve error logging from mpath filter. Check for allocation failure in hold_lock() in clvmd. diff --git a/tools/lvcreate.c b/tools/lvcreate.c index 4feec87b7..eecc08b78 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -652,10 +652,13 @@ static int _lvcreate_params(struct lvcreate_params *lp, else segtype_str = "striped"; - lp->segtype = get_segtype_from_string(cmd, arg_str_value(cmd, type_ARG, segtype_str)); + segtype_str = arg_str_value(cmd, type_ARG, segtype_str); + + if (!(lp->segtype = get_segtype_from_string(cmd, segtype_str))) + return_0; if (seg_unknown(lp)) { - log_error("Unable to create LV with unknown segment type %s.", arg_str_value(cmd, type_ARG, segtype_str)); + log_error("Unable to create LV with unknown segment type %s.", segtype_str); return 0; }