aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/locks.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/locks.c b/fs/locks.c
index 65765cb6afed..61c22f722050 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1504,7 +1504,7 @@ static int do_fcntl_delete_lease(struct file *filp)
1504 1504
1505static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg) 1505static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg)
1506{ 1506{
1507 struct file_lock *fl; 1507 struct file_lock *fl, *ret;
1508 struct fasync_struct *new; 1508 struct fasync_struct *new;
1509 struct inode *inode = filp->f_path.dentry->d_inode; 1509 struct inode *inode = filp->f_path.dentry->d_inode;
1510 int error; 1510 int error;
@@ -1518,6 +1518,7 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg)
1518 locks_free_lock(fl); 1518 locks_free_lock(fl);
1519 return -ENOMEM; 1519 return -ENOMEM;
1520 } 1520 }
1521 ret = fl;
1521 lock_flocks(); 1522 lock_flocks();
1522 error = __vfs_setlease(filp, arg, &fl); 1523 error = __vfs_setlease(filp, arg, &fl);
1523 if (error) { 1524 if (error) {
@@ -1525,6 +1526,8 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg)
1525 locks_free_lock(fl); 1526 locks_free_lock(fl);
1526 goto out_free_fasync; 1527 goto out_free_fasync;
1527 } 1528 }
1529 if (ret != fl)
1530 locks_free_lock(fl);
1528 1531
1529 /* 1532 /*
1530 * fasync_insert_entry() returns the old entry if any. 1533 * fasync_insert_entry() returns the old entry if any.
@@ -1532,7 +1535,7 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg)
1532 * inserted it into the fasync list. Clear new so that 1535 * inserted it into the fasync list. Clear new so that
1533 * we don't release it here. 1536 * we don't release it here.
1534 */ 1537 */
1535 if (!fasync_insert_entry(fd, filp, &fl->fl_fasync, new)) 1538 if (!fasync_insert_entry(fd, filp, &ret->fl_fasync, new))
1536 new = NULL; 1539 new = NULL;
1537 1540
1538 if (error < 0) { 1541 if (error < 0) {