All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zdenek Kabelac <zdenek.kabelac@gmail.com>
To: lvm-devel@redhat.com
Subject: [PATCH 1/3] cmdlib_lvm2_init: release cmd after registration failed
Date: Fri, 10 Sep 2021 17:00:57 +0200	[thread overview]
Message-ID: <098c7489-ffaf-fe4c-aa17-f455c91fcf03@gmail.com> (raw)
In-Reply-To: <e542f440-3c6d-e081-4fa7-2b71f71c448b@huawei.com>

Dne 30. 08. 21 v 9:13 Wu Guanghao napsal(a):
> 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;


Well - all possible paths leading to 'return 0' from lvm_register_commands() 
are essentially  internal errors - so app should crash anyway,
but I guess it does no harm to add 'free()' call - so I'll push it.

Zdenek



  reply	other threads:[~2021-09-10 15:00 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 ` [PATCH 1/3] cmdlib_lvm2_init: release cmd after registration failed Wu Guanghao
2021-09-10 15:00   ` Zdenek Kabelac [this message]
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=098c7489-ffaf-fe4c-aa17-f455c91fcf03@gmail.com \
    --to=zdenek.kabelac@gmail.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.