diff options
author | mckusick <mckusick@FreeBSD.org> | 2014-03-12 01:28:21 +0000 |
---|---|---|
committer | mckusick <mckusick@FreeBSD.org> | 2014-03-12 01:28:21 +0000 |
commit | 0abf3679fe2f3c444ba8417684034d18894b5974 (patch) | |
tree | 0ea9e55e391cc8de48278a15fe8aca8a2d4eaab4 /sbin | |
parent | bf13b5b908b4b81764276a5b3460483720708045 (diff) | |
download | FreeBSD-src-0abf3679fe2f3c444ba8417684034d18894b5974.zip FreeBSD-src-0abf3679fe2f3c444ba8417684034d18894b5974.tar.gz |
Avoid segment fault when attempting to clean up cylinder group
buffer cache.
PR: 187221
Submitted by: Petr Lampa <lampa@fit.vutbr.cz>
Obtained from: Petr Lampa <lampa@fit.vutbr.cz>
MFC after: 1 week
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fsck_ffs/fsutil.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c index 5fe09a0..bc80e2f 100644 --- a/sbin/fsck_ffs/fsutil.c +++ b/sbin/fsck_ffs/fsutil.c @@ -436,13 +436,15 @@ ckfini(int markclean) } if (numbufs != cnt) errx(EEXIT, "panic: lost %d buffers", numbufs - cnt); - for (cnt = 0; cnt < sblock.fs_ncg; cnt++) { - if (cgbufs[cnt].b_un.b_cg == NULL) - continue; - flush(fswritefd, &cgbufs[cnt]); - free(cgbufs[cnt].b_un.b_cg); + if (cgbufs != NULL) { + for (cnt = 0; cnt < sblock.fs_ncg; cnt++) { + if (cgbufs[cnt].b_un.b_cg == NULL) + continue; + flush(fswritefd, &cgbufs[cnt]); + free(cgbufs[cnt].b_un.b_cg); + } + free(cgbufs); } - free(cgbufs); pbp = pdirbp = (struct bufarea *)0; if (cursnapshot == 0 && sblock.fs_clean != markclean) { if ((sblock.fs_clean = markclean) != 0) { |