Skip to content

Commit

Permalink
CIFS: Fix lock consistensy bug in cifs_setlk
Browse files Browse the repository at this point in the history
If we netogiate mandatory locking style, have a read lock and try
to set a write lock we end up with a write lock in vfs cache and
no lock in cifs lock cache - that's wrong. Fix it by returning
from cifs_setlk immediately if a error occurs during setting a lock.

Reviewed-by: Jeff Layton <[email protected]>
Signed-off-by: Pavel Shilovsky <[email protected]>
Signed-off-by: Steve French <[email protected]>
  • Loading branch information
piastry authored and smfrench committed Dec 5, 2012
1 parent f152fd5 commit 21cb2d9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions fs/cifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1443,16 +1443,18 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
return -ENOMEM;

rc = cifs_lock_add_if(cfile, lock, wait_flag);
if (rc < 0)
if (rc < 0) {
kfree(lock);
if (rc <= 0)
return rc;
}
if (!rc)
goto out;

rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length,
type, 1, 0, wait_flag);
if (rc) {
kfree(lock);
goto out;
return rc;
}

cifs_lock_add(cfile, lock);
Expand Down

0 comments on commit 21cb2d9

Please sign in to comment.