aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorPavel Shilovsky <piastry@etersoft.ru>2012-11-22 09:56:39 -0500
committerSteve French <smfrench@gmail.com>2012-12-05 14:27:29 -0500
commit21cb2d90c76cbc951da3a266f0dd439d64f3114a (patch)
treeb38829c87f5be4c9da6c2bfdb11fd5a7ec4e98fb /fs/cifs
parentf152fd5fffa78910c467b17f12d0aa060aa408a6 (diff)
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>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/file.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 67fe0b811f2..bceffa8c034 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1443,16 +1443,18 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
1443 return -ENOMEM; 1443 return -ENOMEM;
1444 1444
1445 rc = cifs_lock_add_if(cfile, lock, wait_flag); 1445 rc = cifs_lock_add_if(cfile, lock, wait_flag);
1446 if (rc < 0) 1446 if (rc < 0) {
1447 kfree(lock); 1447 kfree(lock);
1448 if (rc <= 0) 1448 return rc;
1449 }
1450 if (!rc)
1449 goto out; 1451 goto out;
1450 1452
1451 rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length, 1453 rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length,
1452 type, 1, 0, wait_flag); 1454 type, 1, 0, wait_flag);
1453 if (rc) { 1455 if (rc) {
1454 kfree(lock); 1456 kfree(lock);
1455 goto out; 1457 return rc;
1456 } 1458 }
1457 1459
1458 cifs_lock_add(cfile, lock); 1460 cifs_lock_add(cfile, lock);