Skip to content

Commit a7ac203

Browse files
author
Andreas Gruenbacher
committed
gfs2: Fix "Introduce flag for glock holder auto-demotion"
Function demote_incompat_holders iterates over the list of glock holders with list_for_each_entry, and it then sometimes removes the current holder from the list. This will get the loop stuck; we must use list_for_each_entry_safe instead. Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent f3506ee commit a7ac203

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/gfs2/glock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,14 +411,14 @@ static void do_error(struct gfs2_glock *gl, const int ret)
411411
static void demote_incompat_holders(struct gfs2_glock *gl,
412412
struct gfs2_holder *new_gh)
413413
{
414-
struct gfs2_holder *gh;
414+
struct gfs2_holder *gh, *tmp;
415415

416416
/*
417417
* Demote incompatible holders before we make ourselves eligible.
418418
* (This holder may or may not allow auto-demoting, but we don't want
419419
* to demote the new holder before it's even granted.)
420420
*/
421-
list_for_each_entry(gh, &gl->gl_holders, gh_list) {
421+
list_for_each_entry_safe(gh, tmp, &gl->gl_holders, gh_list) {
422422
/*
423423
* Since holders are at the front of the list, we stop when we
424424
* find the first non-holder.

0 commit comments

Comments
 (0)