]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Add explanatory comments for Coverity false positives.
authorJohn Wolfe <jwolfe@vmware.com>
Fri, 4 Nov 2022 18:45:05 +0000 (11:45 -0700)
committerJohn Wolfe <jwolfe@vmware.com>
Fri, 4 Nov 2022 18:45:05 +0000 (11:45 -0700)
Add comments for two memory leak false positives reported by a
Coverity scan of open-vm-tools.   Don't annotate since the
annotations can't be made specified to the leaked variable, so
that if an actual leak were introduced in the future an annotation
would cause it to be reported as a false positive.

For the same reason, replace a leaked storage annotation added
previously with an explanatory comment.

open-vm-tools/lib/hgfsServer/hgfsServer.c

index 98f5b3f06471022909d8492b16c393a9eca9e375..fa6e6335432ff617f471188ffe04d09054ed9f25 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 1998-2021 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-2022 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
@@ -3427,11 +3427,18 @@ HgfsServerSessionReceive(HgfsPacket *packet,      // IN: Hgfs Packet
    }
 
    /*
-    * Storage pointed at by the variable input was freed either by
-    * HgfsServerProcessRequest at the end of request processing
-    * or by HgfsServerCompleteRequest if there was a protocol error.
+    * Contrary to Coverity analysis, storage pointed to by the variable
+    * "input" is not leaked; it is freed either by HgfsServerProcessRequest
+    * at the end of request processing or by HgfsServerCompleteRequest if
+    * there is a protocol error.  However, no Coverity annotation for
+    * leaked_storage is added here because such an annotation cannot be
+    * made specific to input; as a result, if any actual memory leaks were
+    * to be introduced by a future change, the leaked_storage annotation
+    * would cause such new leaks to be flagged as false positives.
+    *
+    * XXX - can something be done with Coverity function models so that
+    * Coverity stops reporting this?
     */
-   /* coverity[leaked_storage] */
 }
 
 
@@ -5973,6 +5980,18 @@ HgfsServerGetLocalNameInfo(const char *cpName,      // IN:  Cross-platform filen
 
    *bufOut = myBufOut;
 
+   /*
+    * Contrary to Coverity analysis, storage pointed to by the variable
+    * "entry" is not leaked; HgfsCache_Put stores a pointer to it in the
+    * symlink cache.  However, no Coverity annotation for leaked_storage
+    * is added here because such an annotation cannot be made specific to
+    * entry; as a result, if any actual memory leaks were to be introduced
+    * by a future change, the leaked_storage annotation would cause such
+    * new leaks to be flagged as false positives.
+    *
+    * XXX - can something be done with Coverity function models so that
+    * Coverity stops reporting this?
+    */
    return HGFS_NAME_STATUS_COMPLETE;
 
 error:
@@ -8555,6 +8574,19 @@ HgfsServerGetattr(HgfsInputParam *input)  // IN: Input params
    free(localName);
 
    HgfsServerCompleteRequest(status, replyPayloadSize, input);
+
+   /*
+    * Contrary to Coverity analysis, storage pointed to by the variable
+    * "entry" is not leaked; HgfsCache_Put stores a pointer to it in the
+    * symlink cache.  However, no Coverity annotation for leaked_storage
+    * is added here because such an annotation cannot be made specific to
+    * entry; as a result, if any actual memory leaks were to be introduced
+    * by a future change, the leaked_storage annotation would cause such
+    * new leaks to be flagged as false positives.
+    *
+    * XXX - can something be done with Coverity function models so that
+    * Coverity stops reporting this?
+    */
 }