All of lore.kernel.org
 help / color / mirror / Atom feed
* main - cmdlib_lvm2_init: release cmd on failure path
@ 2021-09-13 10:36 Zdenek Kabelac
  0 siblings, 0 replies; only message in thread
From: Zdenek Kabelac @ 2021-09-13 10:36 UTC (permalink / raw)
  To: lvm-devel

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b36ab8a0639e85a5674a83808ccbb526a7191699
Commit:        b36ab8a0639e85a5674a83808ccbb526a7191699
Parent:        cd897e536fb69281d5d8e3e382a3827640913bd1
Author:        Wu Guanghao <wuguanghao3@huawei.com>
AuthorDate:    Mon Aug 30 15:13:00 2021 +0800
Committer:     Zdenek Kabelac <zkabelac@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@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;
 }



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-13 10:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-13 10:36 main - cmdlib_lvm2_init: release cmd on failure path Zdenek Kabelac

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.