From 17ca96bd7a4844ec25ddf4038f6fdbda8560831a Mon Sep 17 00:00:00 2001 From: Grigoriy Orlov Date: Sun, 22 Apr 2001 21:33:47 +0000 Subject: Free fs->fs_contigdirs array only on successful rw->ro update. This fixes "duplicated free" panic. Update file system from read-write to read-only freed memory but may fail later if file system busy. deraadt@ ok. --- sys/ufs/ffs/ffs_vfsops.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sys/ufs/ffs') diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 88fcc43e0fd..ff73d0590a4 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_vfsops.c,v 1.40 2001/04/19 16:22:17 gluk Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.41 2001/04/22 21:33:46 gluk Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -194,7 +194,6 @@ ffs_mount(mp, path, data, ndp, p) mp->mnt_flag &= ~MNT_SOFTDEP; } else error = ffs_flushfiles(mp, flags, p); - free(fs->fs_contigdirs, M_WAITOK); ronly = 1; } @@ -408,6 +407,8 @@ success: fs->fs_ronly = ronly; fs->fs_clean = ronly && (fs->fs_flags & FS_UNCLEAN) == 0 ? 1 : 0; + if (ronly) + free(fs->fs_contigdirs, M_WAITOK); } if (!ronly) { if (mp->mnt_flag & MNT_SOFTDEP) @@ -489,6 +490,7 @@ ffs_reload(mountp, cred, p) */ newfs->fs_csp = fs->fs_csp; newfs->fs_maxcluster = fs->fs_maxcluster; + newfs->fs_ronly = fs->fs_ronly; bcopy(newfs, fs, (u_int)fs->fs_sbsize); if (fs->fs_sbsize < SBSIZE) bp->b_flags |= B_INVAL; -- cgit v1.2.3