Commit a901125c authored by Yan, Zheng's avatar Yan, Zheng Committed by Jeff Layton

locks: fix file_lock deletion inside loop

locks_delete_lock_ctx() is called inside the loop, so we
should use list_for_each_entry_safe.

Fixes: 8634b51f (locks: convert lease handling to file_lock_context)
Signed-off-by: default avatar"Yan, Zheng" <zyan@redhat.com>
Signed-off-by: default avatarJeff Layton <jeff.layton@primarydata.com>
parent 3c435c1e
...@@ -1388,9 +1388,8 @@ any_leases_conflict(struct inode *inode, struct file_lock *breaker) ...@@ -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 __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
{ {
int error = 0; int error = 0;
struct file_lock *new_fl;
struct file_lock_context *ctx = inode->i_flctx; struct file_lock_context *ctx = inode->i_flctx;
struct file_lock *fl; struct file_lock *new_fl, *fl, *tmp;
unsigned long break_time; unsigned long break_time;
int want_write = (mode & O_ACCMODE) != O_RDONLY; int want_write = (mode & O_ACCMODE) != O_RDONLY;
LIST_HEAD(dispose); LIST_HEAD(dispose);
...@@ -1420,7 +1419,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) ...@@ -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 */ 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)) if (!leases_conflict(fl, new_fl))
continue; continue;
if (want_write) { if (want_write) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment