fix memleak in vgchange

(cherry picked from commit 833473d1ce8082c5934771d937dd29a8531c1e20)
This commit is contained in:
yanshuai01 2024-05-24 14:56:10 +08:00 committed by openeuler-sync-bot
parent 444d366f3c
commit b62da39c75
2 changed files with 33 additions and 1 deletions

View File

@ -0,0 +1,28 @@
From 7ec97ed5f2b95585eb1538ee6edeedb7275101eb Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Wed, 12 Jul 2023 14:15:41 +0200
Subject: [PATCH] cov: fix memleak in vgchange
Release allocated vgname from get_single_vgname_cmd_arg()
when it is not returned via *vgname_ret.
---
tools/vgchange.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 63861b5..7a53a7f 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -863,6 +863,8 @@ static int _vgchange_autoactivation_setup(struct cmd_context *cmd,
*flags &= ~READ_WITHOUT_LOCK;
cmd->can_use_one_scan = 0;
}
+
+ free(vgname);
return 1;
}
--
2.27.0

View File

@ -43,7 +43,7 @@
Name: lvm2 Name: lvm2
Version: 2.03.21 Version: 2.03.21
Release: 8 Release: 9
Epoch: 8 Epoch: 8
Summary: Tools for logical volume management Summary: Tools for logical volume management
License: GPLv2+ and LGPLv2.1 and BSD License: GPLv2+ and LGPLv2.1 and BSD
@ -67,6 +67,7 @@ Patch15: 0015-vgchange-acquire-an-exclusive-VG-lock-for-refresh.patch
Patch16: 0016-dm-event-release-buffer-on-dm_event_get_version.patch Patch16: 0016-dm-event-release-buffer-on-dm_event_get_version.patch
Patch17: 0017-clean-up-group-struct-in-_stats_create_group-error-path.patch Patch17: 0017-clean-up-group-struct-in-_stats_create_group-error-path.patch
Patch18: 0018-do-not-pass-empty-string-in-callback.patch Patch18: 0018-do-not-pass-empty-string-in-callback.patch
Patch19: 0019-fix-memleak-in-vgchange.patch
BuildRequires: gcc BuildRequires: gcc
BuildRequires: gcc-c++ BuildRequires: gcc-c++
@ -493,6 +494,9 @@ fi
%changelog %changelog
* Thu May 9 2024 yanshuai <yanshuai@kylinos.cn> - 8:2.03.21-9
- cov: fix memleak in vgchange
* Tue May 7 2024 yanshuai <yanshuai@kylinos.cn> - 8:2.03.21-8 * Tue May 7 2024 yanshuai <yanshuai@kylinos.cn> - 8:2.03.21-8
- pool: do not pass empty string in callback - pool: do not pass empty string in callback