]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
pstore: Check for prz allocation in walker
authorKees Cook <keescook@chromium.org>
Fri, 10 Feb 2017 18:15:34 +0000 (10:15 -0800)
committerKees Cook <keescook@chromium.org>
Mon, 13 Feb 2017 18:25:52 +0000 (10:25 -0800)
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 <keescook@chromium.org>
fs/pstore/ram.c

index 1d887efaaf718c497a233b63286914cd9a498a00..11f918d34b1e50556fda04f6f1f50e62f5dc5e3c 100644 (file)
@@ -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];
@@ -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,