The libufs library needs to track and free the new fs_si structure

in addition to the fs_csp structure that it references.

PR:           247425
Sponsored by: Netflix
This commit is contained in:
Kirk McKusick 2020-06-23 21:28:26 +00:00
parent 7ac5cc13b5
commit 92c839a156
4 changed files with 8 additions and 7 deletions

View File

@ -49,7 +49,7 @@ struct uufsd {
int d_fd; /* raw device file descriptor */
long d_bsize; /* device bsize */
ufs2_daddr_t d_sblock; /* superblock location */
struct csum *d_sbcsum; /* Superblock summary info */
struct fs_summary_info *d_si; /* Superblock summary info */
caddr_t d_inoblock; /* inode block */
uint32_t d_inomin; /* low ino, not ino_t for ABI compat */
uint32_t d_inomax; /* high ino, not ino_t for ABI compat */

View File

@ -88,7 +88,7 @@ sbread(struct uufsd *disk)
disk->d_ufs = 2;
disk->d_bsize = fs->fs_fsize / fsbtodb(fs, 1);
disk->d_sblock = fs->fs_sblockloc / disk->d_bsize;
disk->d_sbcsum = fs->fs_csp;
disk->d_si = fs->fs_si;
return (0);
}

View File

@ -69,9 +69,10 @@ ufs_disk_close(struct uufsd *disk)
free((char *)(uintptr_t)disk->d_name);
disk->d_name = NULL;
}
if (disk->d_sbcsum != NULL) {
free(disk->d_sbcsum);
disk->d_sbcsum = NULL;
if (disk->d_si != NULL) {
free(disk->d_si->si_csp);
free(disk->d_si);
disk->d_si = NULL;
}
return (0);
}
@ -164,7 +165,7 @@ again: if ((ret = stat(name, &st)) < 0) {
disk->d_mine = 0;
disk->d_ufs = 0;
disk->d_error = NULL;
disk->d_sbcsum = NULL;
disk->d_si = NULL;
if (oname != name) {
name = strdup(name);

View File

@ -216,7 +216,7 @@ setup(char *dev)
disk.d_ufs = (sblock.fs_magic == FS_UFS1_MAGIC) ? 1 : 2;
disk.d_bsize = sblock.fs_fsize / fsbtodb(&sblock, 1);
disk.d_sblock = sblock.fs_sblockloc / disk.d_bsize;
disk.d_sbcsum = sblock.fs_csp;
disk.d_si = sblock.fs_si;
if (skipclean && ckclean && sblock.fs_clean) {
pwarn("FILE SYSTEM CLEAN; SKIPPING CHECKS\n");