CIFS: Fix lock consistensy bug in cifs_setlk
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 <jlayton@redhat.com> Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru> Signed-off-by: Steve French <smfrench@gmail.com>
This commit is contained in:
parent
f152fd5fff
commit
21cb2d90c7
|
@ -1443,16 +1443,18 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
rc = cifs_lock_add_if(cfile, lock, wait_flag);
|
rc = cifs_lock_add_if(cfile, lock, wait_flag);
|
||||||
if (rc < 0)
|
if (rc < 0) {
|
||||||
kfree(lock);
|
kfree(lock);
|
||||||
if (rc <= 0)
|
return rc;
|
||||||
|
}
|
||||||
|
if (!rc)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length,
|
rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length,
|
||||||
type, 1, 0, wait_flag);
|
type, 1, 0, wait_flag);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
kfree(lock);
|
kfree(lock);
|
||||||
goto out;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
cifs_lock_add(cfile, lock);
|
cifs_lock_add(cfile, lock);
|
||||||
|
|
Loading…
Reference in New Issue