GFS2: Fix reference to ERR_PTR in gfs2_glock_iter_next
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 14 Dec 2016 14:02:03 +0000 (08:02 -0600)
committerBob Peterson <rpeterso@redhat.com>
Fri, 16 Dec 2016 01:30:07 +0000 (19:30 -0600)
This patch fixes a place where function gfs2_glock_iter_next can
reference an invalid error pointer.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
fs/gfs2/glock.c

index 14cbf60167a7aed5532f5adaf848dd32c432c138..2928f1209b675f828d03305bda8b458b16995ba7 100644 (file)
@@ -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)