From 86d30909829a75c4160a7a8c25fc95704ba857df Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Fri, 17 Mar 2017 09:41:42 -0700 Subject: [PATCH] Tighten lock range error handling If lock_range returns an error then the caller won't unlock the range. Make sure to unlock the range if we have it locked when we get errors that we're going to return to the caller. Signed-off-by: Zach Brown --- kmod/src/lock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kmod/src/lock.c b/kmod/src/lock.c index 1ded4be4..e9f1c5a4 100644 --- a/kmod/src/lock.c +++ b/kmod/src/lock.c @@ -211,9 +211,6 @@ int scoutfs_lock_range_lvb(struct super_block *sb, int mode, goto out; if (linf->shutdown) { - /* unlocked, but we own it */ - if (!list_empty(&lck->head)) - unlock(held, lck); ret = -ESHUTDOWN; goto out; } @@ -231,8 +228,11 @@ int scoutfs_lock_range_lvb(struct super_block *sb, int mode, memcpy(caller_lvb, held->fake_lvb, lvb_len); } } + ret = 0; out: + if (ret < 0 && !list_empty(&lck->head)) + unlock(held, lck); return ret; }