mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
locks: let the caller free file_lock on ->setlease failure
The caller allocated it, the caller should free it. The only issue so far is that we could change the flp pointer even on an error return if the fl_change callback failed. But we can simply move the flp assignment after the fl_change invocation, as the callers don't care about the flp return value if the setlease call failed. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
96f9359345
commit
51ee4b84f5
5 changed files with 13 additions and 17 deletions
20
fs/locks.c
20
fs/locks.c
|
@ -1428,8 +1428,9 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp)
|
|||
goto out;
|
||||
|
||||
if (my_before != NULL) {
|
||||
*flp = *my_before;
|
||||
error = lease->fl_lmops->fl_change(my_before, arg);
|
||||
if (!error)
|
||||
*flp = *my_before;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -1444,8 +1445,6 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp)
|
|||
return 0;
|
||||
|
||||
out:
|
||||
if (arg != F_UNLCK)
|
||||
locks_free_lock(lease);
|
||||
return error;
|
||||
}
|
||||
EXPORT_SYMBOL(generic_setlease);
|
||||
|
@ -1524,8 +1523,11 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg)
|
|||
}
|
||||
lock_flocks();
|
||||
error = __vfs_setlease(filp, arg, &fl);
|
||||
if (error)
|
||||
goto out_unlock;
|
||||
if (error) {
|
||||
unlock_flocks();
|
||||
locks_free_lock(fl);
|
||||
goto out_free_fasync;
|
||||
}
|
||||
|
||||
/*
|
||||
* fasync_insert_entry() returns the old entry if any.
|
||||
|
@ -1541,12 +1543,12 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg)
|
|||
fl->fl_type = F_UNLCK | F_INPROGRESS;
|
||||
fl->fl_break_time = jiffies - 10;
|
||||
time_out_leases(inode);
|
||||
goto out_unlock;
|
||||
} else {
|
||||
error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0);
|
||||
}
|
||||
|
||||
error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0);
|
||||
out_unlock:
|
||||
unlock_flocks();
|
||||
|
||||
out_free_fasync:
|
||||
if (new)
|
||||
fasync_free(new);
|
||||
return error;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue