vol: Don't leak volume bitmaps

Since the original IBM code import, attach2 has set the volume's index
bitmaps to NULL in preparation for allocating and initalizing new
bitmaps.  However, the volume may already have bitmaps from previous
operations, and this is much more likely with DAFS. In this case, the
old bitmaps are leaked.

Instead, free any existing bitmap before allocating a new one.

Discovered via Solaris libumem.so.1.

Reviewed-on: https://gerrit.openafs.org/15428
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 4b42b07fde2cb87ecb0f3135612a4c086227fa09)

Change-Id: I8d67a4ef75218acc6e5852b77b90e7898e78585e
Reviewed-on: https://gerrit.openafs.org/15517
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
This commit is contained in:
Mark Vitale 2023-05-12 23:51:48 -04:00 committed by Stephan Wiesand
parent 3b383abaa9
commit 03bc379df9

View File

@ -3367,6 +3367,8 @@ attach2(Error * ec, VolumeId volumeId, char *path, struct DiskPartition64 *partp
goto locked_error;
}
free(vp->vnodeIndex[vSmall].bitmap);
free(vp->vnodeIndex[vLarge].bitmap);
vp->vnodeIndex[vSmall].bitmap = vp->vnodeIndex[vLarge].bitmap = NULL;
#ifndef BITMAP_LATER
if (programType == fileServer && VolumeWriteable(vp)) {