main - lvm_import_vdo: --dry-run automatically verbose
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3817392d87f24c2d350...
Commit: 3817392d87f24c2d350f801daac2ee16358c1ecf
Parent: 944e560e960964217c7525a18c60bf17ca046e0c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Sep 17 16:49:17 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Sep 17 16:49:17 2021 +0200
lvm_import_vdo: --dry-run automatically verbose
Dry-run is way more usable when it's verbose.
---
man/lvm_import_vdo.8_main | 2 +-
scripts/lvm_import_vdo.sh | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/man/lvm_import_vdo.8_main b/man/lvm_import_vdo.8_main
index c812c5e01..23755a3aa 100644
--- a/man/lvm_import_vdo.8_main
+++ b/man/lvm_import_vdo.8_main
@@ -59,7 +59,7 @@ Answer "yes" at any prompts.
.
.TP
.BR --dry-run
-Print commands without running them.
+Print verbosely commands without running them.
.
.
.SH DIAGNOSTICS
diff --git a/scripts/lvm_import_vdo.sh b/scripts/lvm_import_vdo.sh
index 06cdb106d..7dc326d9f 100755
--- a/scripts/lvm_import_vdo.sh
+++ b/scripts/lvm_import_vdo.sh
@@ -73,7 +73,7 @@ tool_usage() {
echo " -n | --name Specifies VG/LV name for converted VDO volume"
echo " -v | --verbose Be verbose"
echo " -y | --yes Answer \"yes\" at any prompts"
- echo " --dry-run Print commands without running them"
+ echo " --dry-run Print verbosely commands without running them"
exit
}
@@ -434,7 +434,7 @@ do
"-n"|"--name" ) shift; NAME=$1 ;;
"-v"|"--verbose") VERB="-v" ;;
"-y"|"--yes" ) YES="-y" ;;
- "--dry-run" ) DRY="1" ;;
+ "--dry-run" ) DRY="1" ; VERB="-v" ;;
"-*") error "Wrong argument \"$1\". (see: $TOOL --help)" ;;
*) DEVICENAME=$1 ;; # device name does not start with '-'
esac
2 years, 7 months
main - debug: change message level
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=944e560e960964217c7...
Commit: 944e560e960964217c7525a18c60bf17ca046e0c
Parent: ed59b50512f966125b972f9d2eafee3058f8063f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Sep 15 14:04:04 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Sep 15 15:24:56 2021 +0200
debug: change message level
These message do not cause command error - switch to debug.
---
lib/mm/memlock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/mm/memlock.c b/lib/mm/memlock.c
index 1e6cedc5f..3d1a3927c 100644
--- a/lib/mm/memlock.c
+++ b/lib/mm/memlock.c
@@ -357,7 +357,7 @@ static int _memlock_maps(struct cmd_context *cmd, lvmlock_t lock, size_t *mstats
_maps_buffer = line;
}
if (lseek(_maps_fd, 0, SEEK_SET))
- log_sys_error("lseek", _procselfmaps);
+ log_sys_debug("lseek", _procselfmaps);
for (len = 0 ; len < _maps_len; len += n) {
if (!(n = read(_maps_fd, _maps_buffer + len, _maps_len - len)))
break; /* EOF */
@@ -561,7 +561,7 @@ static void _unlock_mem(struct cmd_context *cmd)
if (!_use_mlockall) {
_restore_mmap();
if (close(_maps_fd))
- log_sys_error("close", _procselfmaps);
+ log_sys_debug("close", _procselfmaps);
free(_maps_buffer);
_maps_buffer = NULL;
if (_mstats < unlock_mstats) {
2 years, 7 months
main - cleanup: free already does NULL check
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ed59b50512f966125b9...
Commit: ed59b50512f966125b972f9d2eafee3058f8063f
Parent: 73087c2c0fd51b1ff543580dadbf3d02dd49a35d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Sep 15 14:08:12 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Sep 15 15:24:56 2021 +0200
cleanup: free already does NULL check
Drop extra check for NULL before calling free().
Also drop zeroing data that will be free().
---
daemons/lvmlockd/lvmlockd-core.c | 19 +++++--------------
daemons/lvmlockd/lvmlockd-idm.c | 8 ++++----
2 files changed, 9 insertions(+), 18 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index e53eebfe7..35c9b6c25 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -438,18 +438,11 @@ static void free_pvs_path(struct pvs *pvs)
{
int i;
- for (i = 0; i < pvs->num; i++) {
- if (!pvs->path[i])
- continue;
-
+ for (i = 0; i < pvs->num; i++)
free((char *)pvs->path[i]);
- pvs->path[i] = NULL;
- }
- if (!pvs->path) {
- free(pvs->path);
- pvs->path = NULL;
- }
+ free(pvs->path);
+ pvs->path = NULL;
}
static char **alloc_and_copy_pvs_path(struct pvs *dst, struct pvs *src)
@@ -563,10 +556,8 @@ static struct lock *alloc_lock(void)
static void free_action(struct action *act)
{
- if (act->path) {
- free(act->path);
- act->path = NULL;
- }
+ free(act->path);
+ act->path = NULL;
free_pvs_path(&act->pvs);
diff --git a/daemons/lvmlockd/lvmlockd-idm.c b/daemons/lvmlockd/lvmlockd-idm.c
index e9f50535c..e13fb62ae 100644
--- a/daemons/lvmlockd/lvmlockd-idm.c
+++ b/daemons/lvmlockd/lvmlockd-idm.c
@@ -456,8 +456,9 @@ int lm_add_lockspace_idm(struct lockspace *ls, int adopt)
fail:
if (lmi && lmi->sock)
close(lmi->sock);
- if (lmi)
- free(lmi);
+
+ free(lmi);
+
return rv;
}
@@ -506,8 +507,7 @@ int lm_rem_resource_idm(struct lockspace *ls, struct resource *r)
{
struct rd_idm *rdi = (struct rd_idm *)r->lm_data;
- if (rdi->vb)
- free(rdi->vb);
+ free(rdi->vb);
memset(rdi, 0, sizeof(struct rd_idm));
r->lm_init = 0;
2 years, 7 months
main - clang: free on arg parsing
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=73087c2c0fd51b1ff54...
Commit: 73087c2c0fd51b1ff543580dadbf3d02dd49a35d
Parent: dd5f8b3f8c18ff57525ec5c5b35c6e1d218b1000
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Sep 14 23:06:17 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Sep 15 15:24:56 2021 +0200
clang: free on arg parsing
If the parameter would be given twice, the 1st. alloc memleaks.
---
daemons/lvmlockd/lvmlockd-core.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index a3964c857..e53eebfe7 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -6280,6 +6280,7 @@ int main(int argc, char *argv[])
.daemon_fini = NULL,
.daemon_main = main_loop,
};
+ daemon_host_id_file = NULL;
static struct option long_options[] = {
{"help", no_argument, 0, 'h' },
@@ -6332,9 +6333,11 @@ int main(int argc, char *argv[])
daemon_debug = 1;
break;
case 'p':
+ free((void*)ds.pidfile);
ds.pidfile = strdup(optarg);
break;
case 's':
+ free((void*)ds.socket_path);
ds.socket_path = strdup(optarg);
break;
case 'g':
@@ -6354,6 +6357,7 @@ int main(int argc, char *argv[])
daemon_host_id = atoi(optarg);
break;
case 'F':
+ free((void*)daemon_host_id_file);
daemon_host_id_file = strdup(optarg);
break;
case 'o':
2 years, 7 months
main - clang: keep metaname initialized
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=dd5f8b3f8c18ff57525...
Commit: dd5f8b3f8c18ff57525ec5c5b35c6e1d218b1000
Parent: 1a5c79d1d18cf887646edbdd7e798d93a2f9783f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Sep 15 14:07:19 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Sep 15 15:24:56 2021 +0200
clang: keep metaname initialized
Never access uninitialized metaname buffer.
---
lib/metadata/integrity_manip.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/metadata/integrity_manip.c b/lib/metadata/integrity_manip.c
index c2fd7504c..e053ac5f6 100644
--- a/lib/metadata/integrity_manip.c
+++ b/lib/metadata/integrity_manip.c
@@ -86,7 +86,7 @@ static int _lv_create_integrity_metadata(struct cmd_context *cmd,
struct lvcreate_params *lp,
struct logical_volume **meta_lv)
{
- char metaname[NAME_LEN];
+ char metaname[NAME_LEN] = { 0 };
uint64_t lv_size_bytes, meta_bytes, meta_sectors;
struct logical_volume *lv;
struct lvcreate_params lp_meta = {
2 years, 7 months
main - clang: keep final_opts_list initialized for all paths
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1a5c79d1d18cf887646...
Commit: 1a5c79d1d18cf887646edbdd7e798d93a2f9783f
Parent: 9c5d2874a73d884ede9bb3f0583b238f8764ab92
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Sep 14 19:25:31 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Sep 15 15:24:56 2021 +0200
clang: keep final_opts_list initialized for all paths
Likely impossible path, but just keep always initilized.
---
tools/reporter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/reporter.c b/tools/reporter.c
index 9fb8b128c..54a538d04 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -828,7 +828,7 @@ static int _get_report_options(struct cmd_context *cmd,
{
int action;
struct arg_value_group_list *current_group;
- struct dm_list *final_opts_list[REPORT_IDX_COUNT];
+ struct dm_list *final_opts_list[REPORT_IDX_COUNT] = { NULL };
struct dm_list *opts_list = NULL;
struct dm_str_list *sl;
struct dm_pool *mem;
2 years, 7 months
main - clang: avoid double free on error path
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9c5d2874a73d884ede9...
Commit: 9c5d2874a73d884ede9bb3f0583b238f8764ab92
Parent: 8935dfee56fe2cfb29152f0af2a4c4c32e62895b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Sep 14 18:00:22 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Sep 15 15:24:56 2021 +0200
clang: avoid double free on error path
Error path in _lockd_retrive_vg_pv_list() has not zeroed released path
caussing possible double-free later in the code.
Fix it by using one single function freeing lock_pvs structure.
---
lib/locking/lvmlockd.c | 47 +++++++++++++++--------------------------------
1 file changed, 15 insertions(+), 32 deletions(-)
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index 766be71ba..6eb71d08d 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -232,6 +232,18 @@ static int _lockd_retrive_vg_pv_num(struct volume_group *vg)
return num;
}
+static void _lockd_free_pv_list(struct lvmlockd_pvs *lock_pvs)
+{
+ int i;
+
+ for (i = 0; i < lock_pvs->num; i++)
+ free(lock_pvs->path[i]);
+
+ free(lock_pvs->path);
+ lock_pvs->path = NULL;
+ lock_pvs->num = 0;
+}
+
static void _lockd_retrive_vg_pv_list(struct volume_group *vg,
struct lvmlockd_pvs *lock_pvs)
{
@@ -269,13 +281,7 @@ static void _lockd_retrive_vg_pv_list(struct volume_group *vg,
return;
fail:
- for (i = 0; i < pv_num; i++) {
- if (!lock_pvs->path[i])
- continue;
- free(lock_pvs->path[i]);
- }
- free(lock_pvs->path);
- return;
+ _lockd_free_pv_list(lock_pvs);
}
static int _lockd_retrive_lv_pv_num(struct volume_group *vg,
@@ -327,7 +333,7 @@ static void _lockd_retrive_lv_pv_list(struct volume_group *vg,
}
/* Allocate buffer for PV list */
- lock_pvs->path = malloc(sizeof(*lock_pvs->path) * pv_num);
+ lock_pvs->path = zalloc(sizeof(*lock_pvs->path) * pv_num);
if (!lock_pvs->path) {
log_error("Fail to allocate PV list for %s/%s", vg->name, lv_name);
return;
@@ -352,30 +358,7 @@ static void _lockd_retrive_lv_pv_list(struct volume_group *vg,
return;
fail:
- for (i = 0; i < pv_num; i++) {
- if (!lock_pvs->path[i])
- continue;
- free(lock_pvs->path[i]);
- lock_pvs->path[i] = NULL;
- }
- free(lock_pvs->path);
- lock_pvs->path = NULL;
- lock_pvs->num = 0;
- return;
-}
-
-static void _lockd_free_pv_list(struct lvmlockd_pvs *lock_pvs)
-{
- int i;
-
- for (i = 0; i < lock_pvs->num; i++) {
- free(lock_pvs->path[i]);
- lock_pvs->path[i] = NULL;
- }
-
- free(lock_pvs->path);
- lock_pvs->path = NULL;
- lock_pvs->num = 0;
+ _lockd_free_pv_list(lock_pvs);
}
/*
2 years, 7 months
main - lvmdevices: allow deviceidtype with addpvid
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8935dfee56fe2cfb291...
Commit: 8935dfee56fe2cfb29152f0af2a4c4c32e62895b
Parent: 9857b5a3dc7b23295e47e04c5c338d189c3502d5
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Sep 13 14:11:07 2021 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Sep 13 14:11:07 2021 -0500
lvmdevices: allow deviceidtype with addpvid
in addition to using with adddev
---
tools/command-lines.in | 1 +
tools/lvmdevices.c | 5 +++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/command-lines.in b/tools/command-lines.in
index 73a4c57f9..e63b2bcc3 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -1439,6 +1439,7 @@ ID: lvmdevices_edit
DESC: Remove a device from the devices file.
lvmdevices --addpvid String
+OO: --deviceidtype String
ID: lvmdevices_edit
DESC: Find the device with the given PVID and add it to the devices file.
diff --git a/tools/lvmdevices.c b/tools/lvmdevices.c
index 367536d6a..8d9634848 100644
--- a/tools/lvmdevices.c
+++ b/tools/lvmdevices.c
@@ -127,6 +127,7 @@ int lvmdevices(struct cmd_context *cmd, int argc, char **argv)
struct device_list *devl;
struct device *dev;
struct dev_use *du, *du2;
+ const char *deviceidtype;
int changes = 0;
dm_list_init(&search_pvids);
@@ -269,7 +270,6 @@ int lvmdevices(struct cmd_context *cmd, int argc, char **argv)
if (arg_is_set(cmd, adddev_ARG)) {
const char *devname;
- const char *deviceidtype;
if (!(devname = arg_str_value(cmd, adddev_ARG, NULL)))
goto_bad;
@@ -366,7 +366,8 @@ int lvmdevices(struct cmd_context *cmd, int argc, char **argv)
goto bad;
}
dm_list_iterate_items(devl, &found_devs) {
- if (!device_id_add(cmd, devl->dev, devl->dev->pvid, NULL, NULL))
+ deviceidtype = arg_str_value(cmd, deviceidtype_ARG, NULL);
+ if (!device_id_add(cmd, devl->dev, devl->dev->pvid, deviceidtype, NULL))
goto_bad;
}
if (!device_ids_write(cmd))
2 years, 7 months
main - add --nohints option
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9857b5a3dc7b23295e4...
Commit: 9857b5a3dc7b23295e47e04c5c338d189c3502d5
Parent: b36ab8a0639e85a5674a83808ccbb526a7191699
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Sep 10 15:57:19 2021 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Sep 13 10:55:07 2021 -0500
add --nohints option
The command will not use the hints file to locate devices for PVs.
It will still do standard hint file invalidation where appropriate.
---
test/shell/hints.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++
tools/args.h | 5 +++++
tools/command-lines.in | 2 +-
tools/lvmcmdline.c | 8 ++++++++
4 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/test/shell/hints.sh b/test/shell/hints.sh
index 4fba5cae4..506c005dd 100644
--- a/test/shell/hints.sh
+++ b/test/shell/hints.sh
@@ -37,6 +37,57 @@ aux prepare_devs 6
pvs
not grep scan: $HINTS
+#
+# test --nohints option
+#
+
+pvcreate "$dev1"
+pvcreate "$dev2"
+# pvs --nohints does not create hints
+pvs --nohints |tee out
+grep "$dev1" out
+grep "$dev2" out
+not grep "$dev1" $HINTS
+not grep "$dev2" $HINTS
+# pvs creates hints
+pvs
+grep "$dev1" $HINTS
+grep "$dev2" $HINTS
+
+# save hints with dev1 and dev2 before dev3 is created
+cp $HINTS $PREV
+# pvcreate --nohints invalidates hints
+pvcreate --nohints "$dev3"
+ls $NEWHINTS
+# pvs --nohints does not update hints
+pvs --nohints |tee out
+grep "$dev1" out
+grep "$dev2" out
+grep "$dev3" out
+not grep "$dev3" $HINTS
+# restore old hint file without dev3
+cp $PREV $HINTS
+# pvs --nohints does not update hints
+pvs --nohints |tee out
+grep "$dev1" out
+grep "$dev2" out
+grep "$dev3" out
+grep "$dev1" $HINTS
+grep "$dev2" $HINTS
+not grep "$dev3" $HINTS
+# pvs updates hints
+pvs |tee out
+grep "$dev1" out
+grep "$dev2" out
+grep "$dev3" out
+grep "$dev1" $HINTS
+grep "$dev2" $HINTS
+grep "$dev3" $HINTS
+
+aux wipefs_a "$dev1"
+aux wipefs_a "$dev2"
+aux wipefs_a "$dev3"
+
#
# vg1 uses dev1,dev2
#
@@ -44,6 +95,8 @@ not grep scan: $HINTS
# and that only PVs are scanned when using hints.
#
+rm $HINTS
+
vgcreate $vg1 "$dev1" "$dev2"
lvcreate -n $lv1 -l 4 $vg1
diff --git a/tools/args.h b/tools/args.h
index d4f23f849..05c16d94a 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -460,6 +460,11 @@ arg(noheadings_ARG, '\0', "noheadings", 0, 0, 0,
"Suppress the headings line that is normally the first line of output.\n"
"Useful if grepping the output.\n")
+arg(nohints_ARG, '\0', "nohints", 0, 0, 0,
+ "Do not use the hints file to locate devices for PVs. A command may read\n"
+ "more devices to find PVs when hints are not used. The command will still\n"
+ "perform standard hint file invalidation where appropriate.\n")
+
arg(nohistory_ARG, '\0', "nohistory", 0, 0, 0,
"Do not record history of LVs being removed.\n"
"This has no effect unless the configuration setting\n"
diff --git a/tools/command-lines.in b/tools/command-lines.in
index 0bc5a4989..73a4c57f9 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -204,7 +204,7 @@
#
OO_ALL: --commandprofile String, --config String, --debug,
--driverloaded Bool, --help, --nolocking, --lockopt String, --longhelp, --profile String, --quiet,
---verbose, --version, --yes, --test, --devicesfile String, --devices PV
+--verbose, --version, --yes, --test, --devicesfile String, --devices PV, --nohints
#
# options for pvs, lvs, vgs, fullreport
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index f9eab8ec8..de70e63c9 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -2512,6 +2512,14 @@ static int _get_current_settings(struct cmd_context *cmd)
if (arg_is_set(cmd, sysinit_ARG))
cmd->use_hints = 0;
+ /*
+ * Don't use hints from this command, but enable_hints will
+ * remain set unless hints=none in the config. See above re
+ * the meaning of use_hints=0 && enable_hints=1.
+ */
+ if (arg_is_set(cmd, nohints_ARG))
+ cmd->use_hints = 0;
+
if ((hint_mode = find_config_tree_str(cmd, devices_hints_CFG, NULL))) {
if (!strcmp(hint_mode, "none")) {
cmd->enable_hints = 0;
2 years, 7 months
main - cmdlib_lvm2_init: release cmd on failure path
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b36ab8a0639e85a5674...
Commit: b36ab8a0639e85a5674a83808ccbb526a7191699
Parent: cd897e536fb69281d5d8e3e382a3827640913bd1
Author: Wu Guanghao <wuguanghao3(a)huawei.com>
AuthorDate: Mon Aug 30 15:13:00 2021 +0800
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 13 12:34:41 2021 +0200
cmdlib_lvm2_init: release cmd on failure path
The cmd memory space is allocated by zalloc, and the registration
fails and is not released.
Although this code would be ever triggered just in the case
of some internal (likely compilation) bug.
Signed-off-by: Wu Guanghao <wuguanghao3(a)huawei.com>
---
tools/lvmcmdlib.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/lvmcmdlib.c b/tools/lvmcmdlib.c
index 152d176b2..6b326893c 100644
--- a/tools/lvmcmdlib.c
+++ b/tools/lvmcmdlib.c
@@ -33,8 +33,10 @@ void *cmdlib_lvm2_init(unsigned static_compile, unsigned threaded)
if (!(cmd = init_lvm(1, 1, threaded)))
return NULL;
- if (!lvm_register_commands(cmd, NULL))
+ if (!lvm_register_commands(cmd, NULL)) {
+ free(cmd);
return NULL;
+ }
return (void *) cmd;
}
2 years, 7 months