linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakob Koschel <jkl820.git@gmail.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
	Jeff Layton <jlayton@kernel.org>,
	Chuck Lever <chuck.lever@oracle.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Pietro Borrello <borrello@diag.uniroma1.it>,
	Cristiano Giuffrida <c.giuffrida@vu.nl>,
	"Bos, H.J." <h.j.bos@vu.nl>, Jakob Koschel <jkl820.git@gmail.com>
Subject: [PATCH] locks: avoid usage of list iterator after loop in generic_delete_lease()
Date: Wed, 01 Mar 2023 18:20:18 +0100	[thread overview]
Message-ID: <20230301-locks-avoid-iter-after-loop-v1-1-4d0529b03dc7@gmail.com> (raw)

'victim' and 'fl' are ensured to be equal at this point. For consistency
both should use the same variable.

Additionally, Linus proposed to avoid any use of the list iterator
variable after the loop, in the attempt to move the list iterator
variable declaration into the marcro to avoid any potential misuse after
the loop [1].

Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1]
Signed-off-by: Jakob Koschel <jkl820.git@gmail.com>
---
 fs/locks.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/locks.c b/fs/locks.c
index 66b4eef09db5..3f46d21a95f4 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1841,7 +1841,7 @@ static int generic_delete_lease(struct file *filp, void *owner)
 	}
 	trace_generic_delete_lease(inode, victim);
 	if (victim)
-		error = fl->fl_lmops->lm_change(victim, F_UNLCK, &dispose);
+		error = victim->fl_lmops->lm_change(victim, F_UNLCK, &dispose);
 	spin_unlock(&ctx->flc_lock);
 	percpu_up_read(&file_rwsem);
 	locks_dispose_list(&dispose);

---
base-commit: c0927a7a5391f7d8e593e5e50ead7505a23cadf9
change-id: 20230301-locks-avoid-iter-after-loop-0c6cc0fbd295

Best regards,
-- 
Jakob Koschel <jkl820.git@gmail.com>


             reply	other threads:[~2023-03-01 17:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-01 17:20 Jakob Koschel [this message]
2023-03-02 18:14 ` [PATCH] locks: avoid usage of list iterator after loop in generic_delete_lease() Al Viro
2023-03-02 20:35   ` Jeff Layton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230301-locks-avoid-iter-after-loop-v1-1-4d0529b03dc7@gmail.com \
    --to=jkl820.git@gmail.com \
    --cc=borrello@diag.uniroma1.it \
    --cc=c.giuffrida@vu.nl \
    --cc=chuck.lever@oracle.com \
    --cc=h.j.bos@vu.nl \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).