Skip to content

Commit

Permalink
ubi: Fix seq_file usage in detailed_erase_block_info debugfs file
Browse files Browse the repository at this point in the history
[ Upstream commit 0e7572c ]

3bfa7e1 ("fs/seq_file.c: seq_read(): add info message about buggy .next functions")
showed that we don't use seq_file correctly.
So make sure that our ->next function always updates the position.

Fixes: 7bccd12 ("ubi: Add debugfs file for tracking PEB state")
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
richardweinberger authored and gregkh committed May 27, 2020
1 parent 274cd3c commit 17c9595
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions drivers/mtd/ubi/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,6 @@ static void *eraseblk_count_seq_start(struct seq_file *s, loff_t *pos)
{
struct ubi_device *ubi = s->private;

if (*pos == 0)
return SEQ_START_TOKEN;

if (*pos < ubi->peb_count)
return pos;

Expand All @@ -408,8 +405,6 @@ static void *eraseblk_count_seq_next(struct seq_file *s, void *v, loff_t *pos)
{
struct ubi_device *ubi = s->private;

if (v == SEQ_START_TOKEN)
return pos;
(*pos)++;

if (*pos < ubi->peb_count)
Expand All @@ -431,11 +426,8 @@ static int eraseblk_count_seq_show(struct seq_file *s, void *iter)
int err;

/* If this is the start, print a header */
if (iter == SEQ_START_TOKEN) {
seq_puts(s,
"physical_block_number\terase_count\tblock_status\tread_status\n");
return 0;
}
if (*block_number == 0)
seq_puts(s, "physical_block_number\terase_count\n");

err = ubi_io_is_bad(ubi, *block_number);
if (err)
Expand Down

0 comments on commit 17c9595

Please sign in to comment.