diff options
author | iedowse <iedowse@FreeBSD.org> | 2005-08-17 08:48:42 +0000 |
---|---|---|
committer | iedowse <iedowse@FreeBSD.org> | 2005-08-17 08:48:42 +0000 |
commit | 67b0f0cb388fe1fb060449d04c30351263237151 (patch) | |
tree | 406d46267ec27a1b7e5520b186bb49e6028eabac /sys | |
parent | fcf6768753b6b86c7a8b77348960a06309fd6aaf (diff) | |
download | FreeBSD-src-67b0f0cb388fe1fb060449d04c30351263237151.zip FreeBSD-src-67b0f0cb388fe1fb060449d04c30351263237151.tar.gz |
In the ufsdirhash_build() failure case for corrupted directories
or unreadable blocks, make sure to destroy the mutex we created.
Also fix an unrelated typo in a comment.
Found by: Peter Holm's stress tests
Reviewed by: dwmalone
MFC after: 3 days
Diffstat (limited to 'sys')
-rw-r--r-- | sys/ufs/ufs/ufs_dirhash.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/ufs/ufs/ufs_dirhash.c b/sys/ufs/ufs/ufs_dirhash.c index d8542e8..d15bae1 100644 --- a/sys/ufs/ufs/ufs_dirhash.c +++ b/sys/ufs/ufs/ufs_dirhash.c @@ -188,6 +188,7 @@ ufsdirhash_build(struct inode *ip) DIRHASHLIST_UNLOCK(); return (-1); } + mtx_init(&dh->dh_mtx, "dirhash", NULL, MTX_DEF); MALLOC(dh->dh_hash, doff_t **, narrays * sizeof(dh->dh_hash[0]), M_DIRHASH, M_NOWAIT | M_ZERO); MALLOC(dh->dh_blkfree, u_int8_t *, nblocks * sizeof(dh->dh_blkfree[0]), @@ -202,7 +203,6 @@ ufsdirhash_build(struct inode *ip) } /* Initialise the hash table and block statistics. */ - mtx_init(&dh->dh_mtx, "dirhash", NULL, MTX_DEF); dh->dh_narrays = narrays; dh->dh_hlen = nslots; dh->dh_nblk = nblocks; @@ -265,6 +265,7 @@ fail: } if (dh->dh_blkfree != NULL) FREE(dh->dh_blkfree, M_DIRHASH); + mtx_destroy(&dh->dh_mtx); FREE(dh, M_DIRHASH); ip->i_dirhash = NULL; DIRHASHLIST_LOCK(); @@ -398,7 +399,7 @@ restart: /* * We found an entry with the expected offset. This * is probably the entry we want, but if not, the - * code below will turn off seqoff and retry. + * code below will turn off seqopt and retry. */ slot = i; } else |