afsmonitor: avoid double free on exit 61/13161/7
authorPat Riehecky <riehecky@fnal.gov>
Wed, 6 Jun 2018 15:01:02 +0000 (10:01 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 19 Apr 2019 14:37:17 +0000 (10:37 -0400)
The afsmonitor may leak memory and do a double free on shutdown when it
was started with a non-zero -buffers parameter value. The deallocation
of the cm results circular buffer incorrectly frees the base of the
array of results instead of each result.  The fs buffer clean up got
this right.

This fixes the clang scan-build warning:

    afsmonitor.c:461:7: warning: Attempt to free released memory
                        free(tmp_cmlist);
                        ^~~~~~~~~~~~~~~~

[mmeffie: update code and commit message]

Change-Id: Ifd4ea5b9b865f04e5cf88560dd8a9dfdbe7e32cb
Reviewed-on: https://gerrit.openafs.org/13161
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/afsmonitor/afsmonitor.c

index 6c45843..1f28e3d 100644 (file)
@@ -454,8 +454,8 @@ afsmon_Exit(int a_exitVal)  /* exit code */
                        /* free xstat_cm_Results data */
                        free(tmp_xstat_cmPR->data.AFSCB_CollData_val);
                        free(tmp_xstat_cmPR->connP);
+                       free(tmp_xstat_cmPR);
                    }
-                   free(tmp_cmlist->cmResults);
 
                    /* free the cm list item */
                    free(tmp_cmlist);