diff options
author | Yan, Zheng <zyan@redhat.com> | 2015-03-26 22:34:20 -0400 |
---|---|---|
committer | Jeff Layton <jeff.layton@primarydata.com> | 2015-03-27 07:18:20 -0400 |
commit | a901125c65544aa05c52e1a7388c3900e8af105f (patch) | |
tree | 7fffcbe51519876521a175597428ca7e6e64c0b1 /fs/locks.c | |
parent | 3c435c1e472ba344ee25f795f4807d4457e61f6c (diff) |
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: 8634b51f6ca2 (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>
Diffstat (limited to 'fs/locks.c')
-rw-r--r-- | fs/locks.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/locks.c b/fs/locks.c index 528fedfda15e..40bc384728c0 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -1388,9 +1388,8 @@ any_leases_conflict(struct inode *inode, struct file_lock *breaker) | |||
1388 | int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) | 1388 | int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) |
1389 | { | 1389 | { |
1390 | int error = 0; | 1390 | int error = 0; |
1391 | struct file_lock *new_fl; | ||
1392 | struct file_lock_context *ctx = inode->i_flctx; | 1391 | struct file_lock_context *ctx = inode->i_flctx; |
1393 | struct file_lock *fl; | 1392 | struct file_lock *new_fl, *fl, *tmp; |
1394 | unsigned long break_time; | 1393 | unsigned long break_time; |
1395 | int want_write = (mode & O_ACCMODE) != O_RDONLY; | 1394 | int want_write = (mode & O_ACCMODE) != O_RDONLY; |
1396 | LIST_HEAD(dispose); | 1395 | LIST_HEAD(dispose); |
@@ -1420,7 +1419,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) | |||
1420 | break_time++; /* so that 0 means no break time */ | 1419 | break_time++; /* so that 0 means no break time */ |
1421 | } | 1420 | } |
1422 | 1421 | ||
1423 | list_for_each_entry(fl, &ctx->flc_lease, fl_list) { | 1422 | list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_list) { |
1424 | if (!leases_conflict(fl, new_fl)) | 1423 | if (!leases_conflict(fl, new_fl)) |
1425 | continue; | 1424 | continue; |
1426 | if (want_write) { | 1425 | if (want_write) { |