From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Yan, Zheng" Subject: [PATCH] locks: fix file_lock deletion inside loop Date: Fri, 27 Mar 2015 10:34:20 +0800 Message-ID: <1427423660-6635-1-git-send-email-zyan@redhat.com> Cc: viro@zeniv.linux.org.uk, jeff.layton@primarydata.com, "Yan, Zheng" To: linux-fsdevel@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:33421 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752138AbbC0Cec (ORCPT ); Thu, 26 Mar 2015 22:34:32 -0400 Sender: linux-fsdevel-owner@vger.kernel.org List-ID: locks_delete_lock_ctx() is called inside the loop, so we should use list_for_each_entry_safe. Signed-off-by: Yan, Zheng --- fs/locks.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 528fedf..40bc384 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -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); @@ -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) { -- 1.9.3