All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zdenek Kabelac <zkabelac@sourceware.org>
To: lvm-devel@redhat.com
Subject: main - lvmcache: fix memory leak
Date: Fri, 23 Apr 2021 21:05:35 +0000 (GMT)	[thread overview]
Message-ID: <20210423210535.98130393BC13@sourceware.org> (raw)

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5e8307f4bfc6e04cd601fea78129302ce02ffef8
Commit:        5e8307f4bfc6e04cd601fea78129302ce02ffef8
Parent:        66dd481f46099dd118136dacfad0e815e781605a
Author:        Zdenek Kabelac <zkabelac@redhat.com>
AuthorDate:    Fri Apr 23 14:44:57 2021 +0200
Committer:     Zdenek Kabelac <zkabelac@redhat.com>
CommitterDate: Fri Apr 23 22:54:41 2021 +0200

lvmcache: fix memory leak

With commit 0b18c25d934564015402de33e15a267045ed1b8c there
was introduced  'zalloc()' for allocation of outdates pvs,
but no matching  'free()' is present.
Switch to use cmd mempool instead of adding free() code into
several places.
---
 WHATS_NEW            | 1 +
 lib/cache/lvmcache.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/WHATS_NEW b/WHATS_NEW
index a51e4a05f..7917c2690 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.03.12 - 
 ===================================
+  Fix memleak when generating list of outdated pvs.
   Better hyphenation usage in man pages.
   Replace use of deprecated security_context_t with char*.
   Configure supports AIO_LIBS and AIO_CFLAGS.
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index d4acec509..017134d7d 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -2818,7 +2818,7 @@ void lvmcache_get_outdated_devs(struct cmd_context *cmd,
 	}
 
 	dm_list_iterate_items(info, &vginfo->outdated_infos) {
-		if (!(devl = zalloc(sizeof(*devl))))
+		if (!(devl = dm_pool_zalloc(cmd->mem, sizeof(*devl))))
 			return;
 		devl->dev = info->dev;
 		dm_list_add(devs, &devl->list);



                 reply	other threads:[~2021-04-23 21:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210423210535.98130393BC13@sourceware.org \
    --to=zkabelac@sourceware.org \
    --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.