[PATCH 3/5] pstore: handle zero-sized prz in series
authorMark Salyzyn <salyzyn@google.com>
Mon, 8 Dec 2014 23:06:52 +0000 (15:06 -0800)
committerMark Salyzyn <salyzyn@google.com>
Wed, 14 Jan 2015 00:18:43 +0000 (16:18 -0800)
Corrects a problem wih ramoops_pstore_read failing to
return the next in a prz series after first zero-sized
entry, not venturing to the next non-zero entry.

Signed-off-by: Mark Salyzyn <salyzyn@android.com>
Change-Id: Iedce3b94c13917da33be44e1d80811757774c793

fs/pstore/ram.c

index a05dc23d954c3983166d702e215f1f17a7173b7a..585422d705811c21b314bf9a34ca291ba4e99d5d 100644 (file)
@@ -133,6 +133,12 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max,
        return prz;
 }
 
+static bool prz_ok(struct persistent_ram_zone *prz)
+{
+       return !!prz && !!(persistent_ram_old_size(prz) +
+                          persistent_ram_ecc_string(prz, NULL, 0));
+}
+
 static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
                                   int *count, struct timespec *time,
                                   char **buf, struct pstore_info *psi)
@@ -145,13 +151,13 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
        prz = ramoops_get_next_prz(cxt->przs, &cxt->dump_read_cnt,
                                   cxt->max_dump_cnt, id, type,
                                   PSTORE_TYPE_DMESG, 1);
-       if (!prz)
+       if (!prz_ok(prz))
                prz = ramoops_get_next_prz(&cxt->cprz, &cxt->console_read_cnt,
                                           1, id, type, PSTORE_TYPE_CONSOLE, 0);
-       if (!prz)
+       if (!prz_ok(prz))
                prz = ramoops_get_next_prz(&cxt->fprz, &cxt->ftrace_read_cnt,
                                           1, id, type, PSTORE_TYPE_FTRACE, 0);
-       if (!prz)
+       if (!prz_ok(prz))
                return 0;
 
        /* TODO(kees): Bogus time for the moment. */