From: Jens Axboe Date: Wed, 2 Apr 2014 18:25:16 +0000 (-0600) Subject: Don't crash when using filehash lock before init X-Git-Tag: fio-2.1.8~22 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=45aeca74dc812f33a6617687fc7cb25a1cd2779b;p=fio.git Don't crash when using filehash lock before init We might be parsing and adding files (which locks the hash lock) before we have setup threads. For that case, don't bother locking, we're serialized at that point. Signed-off-by: Jens Axboe --- diff --git a/filehash.c b/filehash.c index c6ebe761..0d61f54c 100644 --- a/filehash.c +++ b/filehash.c @@ -21,12 +21,14 @@ static unsigned short hash(const char *name) void fio_file_hash_lock(void) { - fio_mutex_down(hash_lock); + if (hash_lock) + fio_mutex_down(hash_lock); } void fio_file_hash_unlock(void) { - fio_mutex_up(hash_lock); + if (hash_lock) + fio_mutex_up(hash_lock); } void remove_file_hash(struct fio_file *f)