aboutsummaryrefslogtreecommitdiffstats
path: root/fs/locks.c
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2010-10-30 17:31:14 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-30 21:08:15 -0400
commit096657b65e1ac197e20be5ce7cff6b6ca2532787 (patch)
tree61265f8d8075aee437597ffe050f339b207356e7 /fs/locks.c
parent0ceaf6c700f8245946a163e387add8675a0c302f (diff)
locks: fix leaks on setlease errors
We're depending on setlease to free the passed-in lease on failure. Signed-off-by: J. Bruce Fields <bfields@redhat.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/locks.c')
-rw-r--r--fs/locks.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/locks.c b/fs/locks.c
index 06c77734f589..63fbc41cc573 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1371,20 +1371,22 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp)
1371 struct inode *inode = dentry->d_inode; 1371 struct inode *inode = dentry->d_inode;
1372 int error, rdlease_count = 0, wrlease_count = 0; 1372 int error, rdlease_count = 0, wrlease_count = 0;
1373 1373
1374 lease = *flp;
1375
1376 error = -EACCES;
1374 if ((current_fsuid() != inode->i_uid) && !capable(CAP_LEASE)) 1377 if ((current_fsuid() != inode->i_uid) && !capable(CAP_LEASE))
1375 return -EACCES; 1378 goto out;
1379 error = -EINVAL;
1376 if (!S_ISREG(inode->i_mode)) 1380 if (!S_ISREG(inode->i_mode))
1377 return -EINVAL; 1381 goto out;
1378 error = security_file_lock(filp, arg); 1382 error = security_file_lock(filp, arg);
1379 if (error) 1383 if (error)
1380 return error; 1384 goto out;
1381 1385
1382 time_out_leases(inode); 1386 time_out_leases(inode);
1383 1387
1384 BUG_ON(!(*flp)->fl_lmops->fl_break); 1388 BUG_ON(!(*flp)->fl_lmops->fl_break);
1385 1389
1386 lease = *flp;
1387
1388 if (arg != F_UNLCK) { 1390 if (arg != F_UNLCK) {
1389 error = -EAGAIN; 1391 error = -EAGAIN;
1390 if ((arg == F_RDLCK) && (atomic_read(&inode->i_writecount) > 0)) 1392 if ((arg == F_RDLCK) && (atomic_read(&inode->i_writecount) > 0))