afs: free the Buffers array correctly during shutdown 83/12183/6
authorMark Vitale <mvitale@sinenomine.net>
Fri, 29 Jan 2016 06:30:47 +0000 (01:30 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Thu, 6 May 2021 16:10:43 +0000 (12:10 -0400)
DInit() allocates 'Buffers' with afs_max_buffers = 4*nbuffers
worth of buffer structs to allow for run-time expansion.

But shutdown_bufferpackage() free 'Buffers' as if it only had
nbuffers worth of buffer structs.

Correct the size of Buffers passed to afs_osi_Free().

Discovered during Solaris shutdown testing with kmem_flags=x0f.
This bug is not Solaris-specific, but it may be symptomless on other
platforms.

Introduced by commit e7c966354c428a5a5929a3db6a829ee71c8ba2fc 'Flexible
client buffer growth'; this only affected cold shutdowns (afsd
-shutdown).

After commit 2336164d1bf63980419d3a870f908f1f384fdfc0 'afs: Actually
free resources during warm shutdown', this bug also affects warm
shutdowns (the default when /afs is unmounted).

Change-Id: I6b77f4f8f432a1c20efb1ff2349e349b46a9d58d
Reviewed-on: https://gerrit.openafs.org/12183
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>

src/afs/afs_buffer.c

index ef0ee18..c7a394d 100644 (file)
@@ -642,7 +642,7 @@ shutdown_bufferpackage(void)
     for (i = 0; i < nbuffers; i += NPB, tp += NPB) {
        afs_osi_Free(tp->data, NPB * AFS_BUFFER_PAGESIZE);
     }
-    afs_osi_Free(Buffers, nbuffers * sizeof(struct buffer));
+    afs_osi_Free(Buffers, afs_max_buffers * sizeof(struct buffer));
     Buffers = NULL;
     nbuffers = 0;
     timecounter = 1;