Btrfs-progs: scrub: don't call unlock if pthread_mutex_lock fails

If pthread_mutex_lock fails (rare but fix it anyway), don't call
pthread_mutex_unlock on mutex.

Rationale being that if pthread_mutex_lock fails pthread_mutex_unlock
will always fail and overwrite actual error value in err.

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
This commit is contained in:
Rakesh Pandit 2014-03-15 01:49:45 +02:00 committed by Chris Mason
parent 87d1676b22
commit 5d48302236

View File

@ -776,7 +776,7 @@ static int scrub_write_progress(pthread_mutex_t *m, const char *fsid,
ret = pthread_mutex_lock(m);
if (ret) {
err = -ret;
goto out;
goto fail;
}
ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old);
@ -808,6 +808,7 @@ out:
if (ret && !err)
err = -ret;
fail:
ret = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old);
if (ret && !err)
err = -ret;