121 lines
3.9 KiB
Diff
121 lines
3.9 KiB
Diff
From 0b243aef3307a07fd12171dc82ee3d3b867c3f49 Mon Sep 17 00:00:00 2001
|
|
From: Cathy Avery <cavery@redhat.com>
|
|
Date: Thu, 25 Jul 2019 12:32:35 +0200
|
|
Subject: [PATCH 12/16] Fix [RH Covscan] Coverity reported memory leaks in
|
|
toolboxcmd-stat.c.
|
|
|
|
RH-Author: Cathy Avery <cavery@redhat.com>
|
|
Message-id: <20190725123239.18274-13-cavery@redhat.com>
|
|
Patchwork-id: 89724
|
|
O-Subject: [RHEL8.1 open-vm-tools PATCH 12/16] Fix [RH Covscan] Coverity reported memory leaks in toolboxcmd-stat.c.
|
|
Bugzilla: 1602648
|
|
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
|
|
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
|
commit 46cb6aa361cc8b1d287e3b9b77bf86819b4b1fc5
|
|
Author: Oliver Kurth <okurth@vmware.com>
|
|
Date: Wed May 22 13:09:37 2019 -0700
|
|
|
|
Fix [RH Covscan] Coverity reported memory leaks in toolboxcmd-stat.c.
|
|
|
|
Signed-off-by: Cathy Avery <cavery@redhat.com>
|
|
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
---
|
|
open-vm-tools/toolbox/toolboxcmd-stat.c | 19 +++++++++++--------
|
|
1 file changed, 11 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/toolbox/toolboxcmd-stat.c b/toolbox/toolboxcmd-stat.c
|
|
index 764e4ae..cdd3a70 100644
|
|
--- a/toolbox/toolboxcmd-stat.c
|
|
+++ b/toolbox/toolboxcmd-stat.c
|
|
@@ -1,5 +1,5 @@
|
|
/*********************************************************
|
|
- * Copyright (C) 2008-2016 VMware, Inc. All rights reserved.
|
|
+ * Copyright (C) 2008-2016,2019 VMware, Inc. All rights reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU Lesser General Public License as published
|
|
@@ -56,6 +56,7 @@ OpenHandle(VMGuestLibHandle *glHandle, // OUT: The guestlib handle
|
|
ToolsCmd_PrintErr(SU_(stat.openhandle.failed,
|
|
"OpenHandle failed: %s\n"),
|
|
VMGuestLib_GetErrorText(*glError));
|
|
+ *glHandle = NULL;
|
|
return EX_UNAVAILABLE;
|
|
}
|
|
*glError = VMGuestLib_UpdateInfo(*glHandle);
|
|
@@ -63,6 +64,8 @@ OpenHandle(VMGuestLibHandle *glHandle, // OUT: The guestlib handle
|
|
ToolsCmd_PrintErr(SU_(stat.update.failed,
|
|
"UpdateInfo failed: %s\n"),
|
|
VMGuestLib_GetErrorText(*glError));
|
|
+ VMGuestLib_CloseHandle(*glHandle);
|
|
+ *glHandle = NULL;
|
|
return EX_TEMPFAIL;
|
|
}
|
|
return 0; // We don't return EXIT_SUCCESSS to indicate that this is not
|
|
@@ -192,7 +195,7 @@ StatHostTime(void)
|
|
static int
|
|
StatGetSessionID(void)
|
|
{
|
|
- int exitStatus = EXIT_SUCCESS;
|
|
+ int exitStatus;
|
|
uint64 session;
|
|
VMGuestLibHandle glHandle;
|
|
VMGuestLibError glError;
|
|
@@ -236,7 +239,7 @@ StatGetSessionID(void)
|
|
static int
|
|
StatGetMemoryBallooned(void)
|
|
{
|
|
- int exitStatus = EXIT_SUCCESS;
|
|
+ int exitStatus;
|
|
uint32 memBallooned;
|
|
VMGuestLibHandle glHandle;
|
|
VMGuestLibError glError;
|
|
@@ -280,7 +283,7 @@ StatGetMemoryBallooned(void)
|
|
static int
|
|
StatGetMemoryReservation(void)
|
|
{
|
|
- int exitStatus = EXIT_SUCCESS;
|
|
+ int exitStatus;
|
|
uint32 memReservation;
|
|
VMGuestLibHandle glHandle;
|
|
VMGuestLibError glError;
|
|
@@ -325,7 +328,7 @@ StatGetMemoryReservation(void)
|
|
static int
|
|
StatGetMemorySwapped(void)
|
|
{
|
|
- int exitStatus = EXIT_SUCCESS;
|
|
+ int exitStatus;
|
|
uint32 memSwapped;
|
|
VMGuestLibHandle glHandle;
|
|
VMGuestLibError glError;
|
|
@@ -369,7 +372,7 @@ StatGetMemorySwapped(void)
|
|
static int
|
|
StatGetMemoryLimit(void)
|
|
{
|
|
- int exitStatus = EXIT_SUCCESS;
|
|
+ int exitStatus;
|
|
uint32 memLimit;
|
|
VMGuestLibHandle glHandle;
|
|
VMGuestLibError glError;
|
|
@@ -413,7 +416,7 @@ StatGetMemoryLimit(void)
|
|
static int
|
|
StatGetCpuReservation(void)
|
|
{
|
|
- int exitStatus = EXIT_SUCCESS;
|
|
+ int exitStatus;
|
|
uint32 cpuReservation;
|
|
VMGuestLibHandle glHandle;
|
|
VMGuestLibError glError;
|
|
@@ -457,7 +460,7 @@ StatGetCpuReservation(void)
|
|
static int
|
|
StatGetCpuLimit(void)
|
|
{
|
|
- int exitStatus = EXIT_SUCCESS;
|
|
+ int exitStatus;
|
|
uint32 cpuLimit;
|
|
VMGuestLibHandle glHandle;
|
|
VMGuestLibError glError;
|
|
--
|
|
1.8.3.1
|
|
|