afs: Fix infinite loop found by xfstest generic/676
[sfrench/cifs-2.6.git] / fs / afs / dir.c
index 94aa7356248e2ea0d1ab740f14985b36c15b50b5..79f6b74336d28bb4b4d14189455f8989b2477552 100644 (file)
@@ -463,8 +463,11 @@ static int afs_dir_iterate_block(struct afs_vnode *dvnode,
                }
 
                /* skip if starts before the current position */
-               if (offset < curr)
+               if (offset < curr) {
+                       if (next > curr)
+                               ctx->pos = blkoff + next * sizeof(union afs_xdr_dirent);
                        continue;
+               }
 
                /* found the next entry */
                if (!dir_emit(ctx, dire->u.name, nlen,