Skip to content

Commit 01f6c61

Browse files
Marios Makassikissmfrench
authored andcommitted
ksmbd: Fix resource leak in smb2_lock()
"flock" is leaked if an error happens before smb2_lock_init(), as the lock is not added to the lock_list to be cleaned up. Signed-off-by: Marios Makassikis <[email protected]> Acked-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent bc04441 commit 01f6c61

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/ksmbd/smb2pdu.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6857,6 +6857,7 @@ int smb2_lock(struct ksmbd_work *work)
68576857
if (lock_start > U64_MAX - lock_length) {
68586858
pr_err("Invalid lock range requested\n");
68596859
rsp->hdr.Status = STATUS_INVALID_LOCK_RANGE;
6860+
locks_free_lock(flock);
68606861
goto out;
68616862
}
68626863

@@ -6876,6 +6877,7 @@ int smb2_lock(struct ksmbd_work *work)
68766877
"the end offset(%llx) is smaller than the start offset(%llx)\n",
68776878
flock->fl_end, flock->fl_start);
68786879
rsp->hdr.Status = STATUS_INVALID_LOCK_RANGE;
6880+
locks_free_lock(flock);
68796881
goto out;
68806882
}
68816883

@@ -6887,6 +6889,7 @@ int smb2_lock(struct ksmbd_work *work)
68876889
flock->fl_type != F_UNLCK) {
68886890
pr_err("conflict two locks in one request\n");
68896891
err = -EINVAL;
6892+
locks_free_lock(flock);
68906893
goto out;
68916894
}
68926895
}
@@ -6895,6 +6898,7 @@ int smb2_lock(struct ksmbd_work *work)
68956898
smb_lock = smb2_lock_init(flock, cmd, flags, &lock_list);
68966899
if (!smb_lock) {
68976900
err = -EINVAL;
6901+
locks_free_lock(flock);
68986902
goto out;
68996903
}
69006904
}

0 commit comments

Comments
 (0)