Commit 29dbf546 authored by Oleg Drokin's avatar Oleg Drokin Committed by J. Bruce Fields

lockd: fix a leak in nlmsvc_testlock asynchronous request handling

Without the patch, there is a leakage of nlmblock structure refcount
that holds a reference nlmfile structure, that holds a reference to
struct file, when async GETFL is used (-EINPROGRESS return from
file_ops->lock()), and also in some error cases.

Fix up a style nit while we're here.
Signed-off-by: default avatarOleg Drokin <>
Signed-off-by: default avatarJ. Bruce Fields <>
parent 406a7ea9
......@@ -501,25 +501,29 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
block, block->b_flags, block->b_fl);
if (block->b_flags & B_TIMED_OUT) {
return nlm_lck_denied;
ret = nlm_lck_denied;
goto out;
if (block->b_flags & B_GOT_CALLBACK) {
if (block->b_fl != NULL
&& block->b_fl->fl_type != F_UNLCK) {
lock->fl = *block->b_fl;
goto conf_lock;
else {
} else {
return nlm_granted;
ret = nlm_granted;
goto out;
return nlm_drop_reply;
ret = nlm_drop_reply;
goto out;
error = vfs_test_lock(file->f_file, &lock->fl);
if (error == -EINPROGRESS)
return nlmsvc_defer_lock_rqst(rqstp, block);
if (error == -EINPROGRESS) {
ret = nlmsvc_defer_lock_rqst(rqstp, block);
goto out;
if (error) {
ret = nlm_lck_denied_nolocks;
goto out;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment