From: Michael Meffie Date: Sat, 10 Apr 2010 02:31:24 +0000 (-0400) Subject: afsmonitor: fix segv on exit X-Git-Tag: openafs-devel-1_5_74~40 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=8d9bb0defb3f63640d557b377fa937d0db0de013;p=packages%2Fo%2Fopenafs.git afsmonitor: fix segv on exit Fix crash during afsmonitor shutdown when monitoring multiple fileserver or clients. Change-Id: I5fa5cb7d89dbdfcc5f97541a0e0c6b0836d558b1 Reviewed-on: http://gerrit.openafs.org/1735 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/afsmonitor/afsmonitor.c b/src/afsmonitor/afsmonitor.c index 84a73b216..184a0f9ba 100644 --- a/src/afsmonitor/afsmonitor.c +++ b/src/afsmonitor/afsmonitor.c @@ -362,7 +362,7 @@ afsmon_Exit(int a_exitVal) /* exit code */ struct afsmon_cm_Results_list *next_cmlist; struct xstat_cm_ProbeResults *tmp_xstat_cmPR; struct afsmon_hostEntry *curr_hostEntry; - struct afsmon_hostEntry *prev_hostEntry; + struct afsmon_hostEntry *next_hostEntry; int i; int j; int bufslot; @@ -507,14 +507,12 @@ afsmon_Exit(int a_exitVal) /* exit code */ if (afsmon_debug) fprintf(debugFD, "Deallocating FS hostEntries .."); curr_hostEntry = FSnameList; - for (i = 0; i < numFS; i++) { - prev_hostEntry = curr_hostEntry; + while (curr_hostEntry) { + next_hostEntry = curr_hostEntry->next; if (curr_hostEntry->thresh != NULL) free(curr_hostEntry->thresh); free(curr_hostEntry); - if (afsmon_debug) - fprintf(debugFD, " %d", i); - curr_hostEntry = prev_hostEntry->next; + curr_hostEntry = next_hostEntry; } if (afsmon_debug) fprintf(debugFD, "\n"); @@ -523,14 +521,12 @@ afsmon_Exit(int a_exitVal) /* exit code */ if (afsmon_debug) fprintf(debugFD, "Deallocating CM hostEntries .."); curr_hostEntry = CMnameList; - for (i = 0; i < numCM; i++) { - prev_hostEntry = curr_hostEntry; + while (curr_hostEntry) { + next_hostEntry = curr_hostEntry->next; if (curr_hostEntry->thresh != NULL) free(curr_hostEntry->thresh); free(curr_hostEntry); - if (afsmon_debug) - fprintf(debugFD, " %d", i); - curr_hostEntry = prev_hostEntry->next; + curr_hostEntry = next_hostEntry; } if (afsmon_debug) fprintf(debugFD, "\n");