Skip to content

Commit

Permalink
locks: fix file_lock deletion inside loop
Browse files Browse the repository at this point in the history
locks_delete_lock_ctx() is called inside the loop, so we
should use list_for_each_entry_safe.

Fixes: 8634b51 (locks: convert lease handling to file_lock_context)
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
  • Loading branch information
Yan, Zheng authored and Jeff Layton committed Mar 27, 2015
1 parent 3c435c1 commit a901125
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions fs/locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1388,9 +1388,8 @@ any_leases_conflict(struct inode *inode, struct file_lock *breaker)
int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
{
int error = 0;
struct file_lock *new_fl;
struct file_lock_context *ctx = inode->i_flctx;
struct file_lock *fl;
struct file_lock *new_fl, *fl, *tmp;
unsigned long break_time;
int want_write = (mode & O_ACCMODE) != O_RDONLY;
LIST_HEAD(dispose);
Expand Down Expand Up @@ -1420,7 +1419,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
break_time++; /* so that 0 means no break time */
}

list_for_each_entry(fl, &ctx->flc_lease, fl_list) {
list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_list) {
if (!leases_conflict(fl, new_fl))
continue;
if (want_write) {
Expand Down

0 comments on commit a901125

Please sign in to comment.