On Fri, 24 Jan 2020 08:48:55 +0300 Vasily Averin <vvs@xxxxxxxxxxxxx> wrote: $SUBJECT: "s390/cio: ..." ? > if seq_file .next fuction does not change position index, > read after some lseek can generate unexpected output. > Fixes: 678a395b356a ("[PATCH] s390: convert /proc/cio_ignore") > https://bugzilla.kernel.org/show_bug.cgi?id=206283 > Signed-off-by: Vasily Averin <vvs@xxxxxxxxxxxxx> > --- > drivers/s390/cio/blacklist.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c > index 2a3f874..9cebff8 100644 > --- a/drivers/s390/cio/blacklist.c > +++ b/drivers/s390/cio/blacklist.c > @@ -303,8 +303,10 @@ struct ccwdev_iter { > cio_ignore_proc_seq_next(struct seq_file *s, void *it, loff_t *offset) > { > struct ccwdev_iter *iter; > + loff_t p = *offset; I was asking myself if we could avoid the new variable, but anything I could think of looked worse. > > - 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 @@ struct ccwdev_iter { > return NULL; > } else > iter->devno++; > - (*offset)++; > return iter; > } > Reviewed-by: Cornelia Huck <cohuck@xxxxxxxxxx>