locks: avoid usage of list iterator after loop in generic_delete_lease()
Subsystems (2)
PATCH 1/1 locks: avoid usage of list iterator after loop in generic_delete_lease()
'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].
--- fs/locks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/locks.c +1 -1
@@ -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,
Signature · 1 line
Jakob Koschel <[email protected]>
Al Viro
maintainerQuoted 10 lines · Jakob Koschel
'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].
Looks sane. Jeff, which tree do you want that to go through?
Quoted 9 lines · Al Viro
Quoted 8 lines · Jakob Koschel
'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].
Quoted 4 lines
Quoted 2 lines
Looks sane. Jeff, which tree do you want that to go through?
Looks good to me too. I'm fine if you want to pick up that one, but otherwise I can take it. You can also add:
Thanks!