1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

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@huawei.com>
This commit is contained in:
Wu Guanghao 2021-08-30 15:13:00 +08:00 committed by Zdenek Kabelac
parent cd897e536f
commit b36ab8a063

View File

@ -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;
}