Btrfs-progs: scrub: don't call unlock if pthread_mutex_lock fails
PATCH 1/1 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.
Signed-off-by Rakesh Pandit <[email protected]>
--- cmds-scrub.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
cmds-scrub.c +2 -1
@@ -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;
Signature · 1 line
1.8.5.3
Hi,
Forgot to mention the reason for change. If accepted this can be included in commit message:
Quoted 3 lines · Rakesh Pandit
If
pthread_mutex_lockfails (rare but fix it anyway), don't callpthread_mutex_unlockon mutex.
Rationale being that if pthread_mutex_lock fails pthread_mutex_unlock will always fail and overwrite actual error value in err.
Quoted 1 line
Signed-off-by Rakesh Pandit <[email protected]>
regards,
Quoted 5 lines · Rakesh Pandit
Forgot to mention the reason for change. If accepted this can be included in commit message:
Rationale being that if
pthread_mutex_lockfailspthread_mutex_unlockwill always fail and overwrite actual error value in err.
Thanks, updated.