All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wu Guanghao <wuguanghao3@huawei.com>
To: lvm-devel@redhat.com
Subject: [PATCH 1/3] cmdlib_lvm2_init: release cmd after registration failed
Date: Mon, 30 Aug 2021 15:13:00 +0800	[thread overview]
Message-ID: <e542f440-3c6d-e081-4fa7-2b71f71c448b@huawei.com> (raw)
In-Reply-To: <ad63f240-4bc9-9d54-616c-5c7306b5ee98@huawei.com>

The cmd memory space is allocated by zalloc, and the registration fails and is not released

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



  reply	other threads:[~2021-08-30  7:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-30  7:12 [PATCH 0/3] cov: fix memory leak caused by abnormal exit Wu Guanghao
2021-08-30  7:13 ` Wu Guanghao [this message]
2021-09-10 15:00   ` [PATCH 1/3] cmdlib_lvm2_init: release cmd after registration failed Zdenek Kabelac
2021-08-30  7:13 ` [PATCH 2/3] read_adopt_file: release r when exiting abnormally Wu Guanghao
2021-08-30  7:14 ` [PATCH 3/3] read_adopt_file: fix memory leak Wu Guanghao
2021-09-10  2:21 ` [PATCH 0/3] cov: fix memory leak caused by abnormal exit Zhiqiang Liu
2021-09-10 13:11   ` David Teigland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e542f440-3c6d-e081-4fa7-2b71f71c448b@huawei.com \
    --to=wuguanghao3@huawei.com \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.