Blame SOURCES/ovt-Fix-RH-Covscan-Coverity-reported-memory-leaks-in-too.patch

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