Skip to content

Commit

Permalink
pstore: Check for prz allocation in walker
Browse files Browse the repository at this point in the history
Instead of needing additional checks in callers for unallocated przs,
perform the check in the walker, which gives us a more universal way to
handle the situation.

Signed-off-by: Kees Cook <[email protected]>
  • Loading branch information
kees committed Feb 13, 2017
1 parent 76d5692 commit 4641841
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/pstore/ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max,
struct persistent_ram_zone *prz;
int i = (*c)++;

if (i >= max)
/* Give up if we never existed or have hit the end. */
if (!przs || i >= max)
return NULL;

prz = przs[i];
Expand Down Expand Up @@ -280,7 +281,7 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
1, id, type, PSTORE_TYPE_PMSG, 0);

/* ftrace is last since it may want to dynamically allocate memory. */
if (!prz_ok(prz) && cxt->fprzs) {
if (!prz_ok(prz)) {
if (!(cxt->flags & RAMOOPS_FLAG_FTRACE_PER_CPU)) {
prz = ramoops_get_next_prz(cxt->fprzs,
&cxt->ftrace_read_cnt, 1, id, type,
Expand Down

0 comments on commit 4641841

Please sign in to comment.