s390/cio: cio_ignore_proc_seq_next should increase position index
authorVasily Averin <vvs@virtuozzo.com>
Fri, 24 Jan 2020 05:48:55 +0000 (08:48 +0300)
committerVasily Gorbik <gor@linux.ibm.com>
Mon, 17 Feb 2020 17:01:57 +0000 (18:01 +0100)
if seq_file .next fuction does not change position index,
read after some lseek can generate unexpected output.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=206283
Link: https://lore.kernel.org/r/d44c53a7-9bc1-15c7-6d4a-0c10cb9dffce@virtuozzo.com
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
drivers/s390/cio/blacklist.c

index da642e811f7f06853ed77defd599afa0eab98a37..4dd2eb6348569965dc4df362e8a6a6f689976f3a 100644 (file)
@@ -303,8 +303,10 @@ static void *
 cio_ignore_proc_seq_next(struct seq_file *s, void *it, loff_t *offset)
 {
        struct ccwdev_iter *iter;
+       loff_t p = *offset;
 
-       if (*offset >= (__MAX_SUBCHANNEL + 1) * (__MAX_SSID + 1))
+       (*offset)++;
+       if (p >= (__MAX_SUBCHANNEL + 1) * (__MAX_SSID + 1))
                return NULL;
        iter = it;
        if (iter->devno == __MAX_SUBCHANNEL) {
@@ -314,7 +316,6 @@ cio_ignore_proc_seq_next(struct seq_file *s, void *it, loff_t *offset)
                        return NULL;
        } else
                iter->devno++;
-       (*offset)++;
        return iter;
 }