summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2012-03-01 17:59:35 +0100
committerZdenek Kabelac <zkabelac@redhat.com>2012-08-23 14:38:48 +0200
commit0de57b98bf0778684e8fac6d2d66ecf3fbc035ab (patch)
tree6e290b2f768bc4c444fe752c7226f31a16292485
parenteb08f8652125513761e83c324a2c7e706ccda791 (diff)
downloadlvm2-0de57b98bf0778684e8fac6d2d66ecf3fbc035ab.zip
lvm2-0de57b98bf0778684e8fac6d2d66ecf3fbc035ab.tar.gz
lvm2-0de57b98bf0778684e8fac6d2d66ecf3fbc035ab.tar.xz
lvmapi: validate extents size for lvcreate
-rw-r--r--liblvm/lvm_lv.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/liblvm/lvm_lv.c b/liblvm/lvm_lv.c
index 23ccbe8..2d4dc02 100644
--- a/liblvm/lvm_lv.c
+++ b/liblvm/lvm_lv.c
@@ -153,15 +153,18 @@ lv_t lvm_vg_create_lv_linear(vg_t vg, const char *name, uint64_t size)
if (!vg_check_write_mode(vg))
return NULL;
- extents = extents_from_size(vg->cmd, size / SECTOR_SIZE,
- vg->extent_size);
+ if (!(extents = extents_from_size(vg->cmd, size / SECTOR_SIZE,
+ vg->extent_size))) {
+ log_error("Unable to create LV without size.");
+ return NULL;
+ }
+
_lv_set_default_params(&lp, vg, name, extents);
if (!_lv_set_default_linear_params(vg->cmd, &lp))
return_NULL;
if (!lv_create_single(vg, &lp))
- return NULL;
- lvl = find_lv_in_vg(vg, name);
- if (!lvl)
+ return_NULL;
+ if (!(lvl = find_lv_in_vg(vg, name)))
return NULL;
return (lv_t) lvl->lv;
}