Re: [PATCH v2] pstore: pstore_ftrace_seq_next should increase position index

From: Kees Cook
Date: Wed Feb 26 2020 - 13:40:51 EST


On Wed, Feb 26, 2020 at 01:36:45PM -0500, Joel Fernandes wrote:
> One thing I was not sure about is, if we move "pos" forward but still
> return NULL from next(), then does show() need to check if data is
> NULL? As below. Otherwise the suggested patch looks sane to me.
>
> diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
> index 7fbe8f0582205..e3e7370b1a34d 100644
> --- a/fs/pstore/inode.c
> +++ b/fs/pstore/inode.c
> @@ -101,6 +101,9 @@ static int pstore_ftrace_seq_show(struct seq_file
> *s, void *v)
> struct pstore_ftrace_seq_data *data = v;
> struct pstore_ftrace_record *rec;
>
> + if (!data)
> + return 0;
> +
> rec = (struct pstore_ftrace_record *)(ps->record->buf + data->off);
>
> seq_printf(s, "CPU:%d ts:%llu %08lx %08lx %ps <- %pS\n",

Ah, good point. I'm not sure, but it's worth checking I think. :)

--
Kees Cook