* [PATCH] net: atm: fix update of position index in lec_seq_next
@ 2020-10-27 11:49 Colin King
2020-10-31 19:32 ` Jakub Kicinski
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2020-10-27 11:49 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, netdev; +Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
The position index in leq_seq_next is not updated when the next
entry is fetched an no more entries are available. This causes
seq_file to report the following error:
"seq_file: buggy .next function lec_seq_next [lec] did not update
position index"
Fix this by always updating the position index.
[ Note: this is an ancient 2002 bug, the sha is from the
tglx/history repo ]
Fixes 4aea2cbff417 ("[ATM]: Move lan seq_file ops to lec.c [1/3]")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
net/atm/lec.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/atm/lec.c b/net/atm/lec.c
index dbabb65d8b67..7226c784dbe0 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -954,9 +954,8 @@ static void *lec_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
struct lec_state *state = seq->private;
- v = lec_get_idx(state, 1);
- *pos += !!PTR_ERR(v);
- return v;
+ ++*pos;
+ return lec_get_idx(state, 1);
}
static int lec_seq_show(struct seq_file *seq, void *v)
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: atm: fix update of position index in lec_seq_next
2020-10-27 11:49 [PATCH] net: atm: fix update of position index in lec_seq_next Colin King
@ 2020-10-31 19:32 ` Jakub Kicinski
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2020-10-31 19:32 UTC (permalink / raw)
To: Colin King; +Cc: David S . Miller, netdev, kernel-janitors, linux-kernel
On Tue, 27 Oct 2020 11:49:25 +0000 Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The position index in leq_seq_next is not updated when the next
> entry is fetched an no more entries are available. This causes
> seq_file to report the following error:
>
> "seq_file: buggy .next function lec_seq_next [lec] did not update
> position index"
>
> Fix this by always updating the position index.
>
> [ Note: this is an ancient 2002 bug, the sha is from the
> tglx/history repo ]
>
> Fixes 4aea2cbff417 ("[ATM]: Move lan seq_file ops to lec.c [1/3]")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Applied, very sneaky there with the lack of a colon on the Fixes tag :)
BTW looking at seq_read() it seems to eat the potential error code from
->next, doesn't it?
@@ -254,9 +254,11 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
}
m->op->stop(m, p);
n = min(m->count, size);
- err = copy_to_user(buf, m->buf, n);
- if (err)
- goto Efault;
+ if (n) {
+ err = copy_to_user(buf, m->buf, n);
+ if (err)
+ goto Efault;
+ }
copied += n;
m->count -= n;
m->from = n;
Maybe? Or at least:
@@ -239,10 +239,8 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
m->op->next);
m->index++;
}
- if (!p || IS_ERR(p)) {
- err = PTR_ERR(p);
+ if (!p || IS_ERR(p))
break;
- }
if (m->count >= size)
break;
err = m->op->show(m, p);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-31 19:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-27 11:49 [PATCH] net: atm: fix update of position index in lec_seq_next Colin King
2020-10-31 19:32 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).