All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [patch] GFS2: Fix reference to ERR_PTR in gfs2_glock_iter_next
Date: Wed, 14 Dec 2016 17:26:38 +0300	[thread overview]
Message-ID: <20161214142638.GA10918@elgon.mountain> (raw)
In-Reply-To: <533897646.11668780.1481724307206.JavaMail.zimbra@redhat.com>

If rhashtable_walk_next() returned PTR_ERR(-EAGAIN) then that would
cause an Oops.

Fixes: 88ffbf3e037e ("GFS2: Use resizable hash table for glocks")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Is the comment in the right place?  If not then please just fix it and
give me Reported-by credit.

diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 14cbf60167a7..2928f1209b67 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -1802,16 +1802,18 @@ void gfs2_glock_exit(void)
 
 static void gfs2_glock_iter_next(struct gfs2_glock_iter *gi)
 {
-	do {
-		gi->gl = rhashtable_walk_next(&gi->hti);
+	while ((gi->gl = rhashtable_walk_next(&gi->hti))) {
 		if (IS_ERR(gi->gl)) {
 			if (PTR_ERR(gi->gl) == -EAGAIN)
 				continue;
 			gi->gl = NULL;
+			return;
 		}
-	/* Skip entries for other sb and dead entries */
-	} while ((gi->gl) && ((gi->sdp != gi->gl->gl_name.ln_sbd) ||
-			      __lockref_is_dead(&gi->gl->gl_lockref)));
+		/* Skip entries for other sb and dead entries */
+		if (gi->sdp == gi->gl->gl_name.ln_sbd &&
+		    !__lockref_is_dead(&gi->gl->gl_lockref))
+			return;
+	}
 }
 
 static void *gfs2_glock_seq_start(struct seq_file *seq, loff_t *pos)



  parent reply	other threads:[~2016-12-14 14:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-14  8:58 [Cluster-devel] [bug report] GFS2: Use resizable hash table for glocks Dan Carpenter
2016-12-14 13:41 ` Bob Peterson
2016-12-14 14:05   ` Bob Peterson
2016-12-14 14:25     ` Dan Carpenter
2016-12-14 14:26     ` Dan Carpenter [this message]
2016-12-16 13:22       ` [Cluster-devel] [patch] GFS2: Fix reference to ERR_PTR in gfs2_glock_iter_next Bob Peterson
2016-12-14 14:08   ` [Cluster-devel] [bug report] GFS2: Use resizable hash table for glocks Dan Carpenter

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=20161214142638.GA10918@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.