|
|
510c97 |
From 1df114456e53479bad9ece58f2fb6602dc31b9af Mon Sep 17 00:00:00 2001
|
|
|
510c97 |
From: Cathy Avery <cavery@redhat.com>
|
|
|
510c97 |
Date: Thu, 25 Mar 2021 13:18:52 -0400
|
|
|
510c97 |
Subject: [PATCH] Fix memory leaks in guestInfo/diskInfo.c.
|
|
|
510c97 |
|
|
|
510c97 |
RH-Author: Cathy Avery <cavery@redhat.com>
|
|
|
510c97 |
RH-MergeRequest: 1: Fix memory leaks in guestInfo/diskInfo.c.
|
|
|
510c97 |
RH-Commit: [1/1] ddc8da05f5d6ae36d32b99a8100026f3ac1badbe (cavery/open-vm-tools)
|
|
|
510c97 |
RH-Bugzilla: 1937420
|
|
|
510c97 |
RH-Acked-by: Acked-by: Mohammed Gamal <mgamal@redhat.com>
|
|
|
510c97 |
RH-Acked-by: Acked-by: Vitaly Kuznetsov vkuznets@redhat.com
|
|
|
510c97 |
|
|
|
510c97 |
When checking for IDE, SATA and SAS disk drives, the glib GMatchInfo is
|
|
|
510c97 |
passed to a g_regex_match() function inside a for loop. It was not
|
|
|
510c97 |
properly passed to g_match_info_free() before subsequently being reused.
|
|
|
510c97 |
|
|
|
510c97 |
This addresses https://github.com/vmware/open-vm-tools/issues/452
|
|
|
510c97 |
|
|
|
510c97 |
(cherry picked from commit 25c2e973583cf189995c9638701e4bef9e1c851c)
|
|
|
510c97 |
Signed-off-by: Cathy Avery <cavery@redhat.com>
|
|
|
510c97 |
---
|
|
|
510c97 |
open-vm-tools/services/plugins/guestInfo/diskInfo.c | 4 ++++
|
|
|
510c97 |
1 file changed, 4 insertions(+)
|
|
|
510c97 |
|
|
|
510c97 |
diff --git a/open-vm-tools/services/plugins/guestInfo/diskInfo.c b/open-vm-tools/services/plugins/guestInfo/diskInfo.c
|
|
|
510c97 |
index 032c0928..e63d232a 100644
|
|
|
510c97 |
--- a/open-vm-tools/services/plugins/guestInfo/diskInfo.c
|
|
|
510c97 |
+++ b/open-vm-tools/services/plugins/guestInfo/diskInfo.c
|
|
|
510c97 |
@@ -270,6 +270,7 @@ GuestInfoGetIdeSataDev(const char *tgtHostPath,
|
|
|
510c97 |
regexAtaOrHost = regexAta;
|
|
|
510c97 |
|
|
|
510c97 |
} else {
|
|
|
510c97 |
+ g_match_info_free(matchInfo);
|
|
|
510c97 |
COMP_STATIC_REGEX(regexHostPath, "^.*/host(\\d+)$", gErr, exit)
|
|
|
510c97 |
if (g_regex_match(regexHostPath, realPath, 0, &matchInfo)) {
|
|
|
510c97 |
COMP_STATIC_REGEX(regexHost, "^host(\\d+)$", gErr, exit)
|
|
|
510c97 |
@@ -296,6 +297,7 @@ GuestInfoGetIdeSataDev(const char *tgtHostPath,
|
|
|
510c97 |
for (fileNum = 0; fileNum < numFiles; fileNum++) {
|
|
|
510c97 |
int currHost;
|
|
|
510c97 |
|
|
|
510c97 |
+ g_match_info_free(matchInfo);
|
|
|
510c97 |
if (g_regex_match(regexAtaOrHost, fileNameList[fileNum], 0, &matchInfo)) {
|
|
|
510c97 |
g_free(charHost);
|
|
|
510c97 |
charHost = g_match_info_fetch(matchInfo, 1);
|
|
|
510c97 |
@@ -431,6 +433,7 @@ GuestInfoCheckSASDevice(char *pciDevPath,
|
|
|
510c97 |
pciDevPath);
|
|
|
510c97 |
}
|
|
|
510c97 |
for (fileNum = 0; fileNum < numFiles; fileNum++) {
|
|
|
510c97 |
+ g_match_info_free(matchInfo);
|
|
|
510c97 |
if (g_regex_match(regexSas, fileNameList[fileNum], 0, &matchInfo)) {
|
|
|
510c97 |
free(*unit); /* free previous "unit" string */
|
|
|
510c97 |
*unit = g_match_info_fetch(matchInfo, 1);
|
|
|
510c97 |
@@ -659,6 +662,7 @@ GuestInfoLinuxBlockDevice(const char *startPath,
|
|
|
510c97 |
/* Check for NVMe device. */
|
|
|
510c97 |
COMP_STATIC_REGEX(regexNvme, "^.*/nvme\\d+$", gErr, finished)
|
|
|
510c97 |
|
|
|
510c97 |
+ g_match_info_free(matchInfo);
|
|
|
510c97 |
if (!g_regex_match(regexNvme, realPath, 0, &matchInfo)) {
|
|
|
510c97 |
g_debug("%s: block disk device pattern not found\n", __FUNCTION__);
|
|
|
510c97 |
goto finished;
|
|
|
510c97 |
--
|
|
|
510c97 |
2.27.0
|
|
|
510c97 |
|