pstore/ram: Fix console ramoops to show the previous boot logs

commit b05c950698fe ("pstore/ram: Simplify ramoops_get_next_prz()
arguments") changed update assignment in getting next persistent ram zone
by adding a check for record type. But the check always returns true since
the record type is assigned 0. And this breaks console ramoops by showing
current console log instead of previous log on warm reset and hard reset
(actually hard reset should not be showing any logs).

Fix this by having persistent ram zone type check instead of record type
check. Tested this on SDM845 MTP and dragonboard 410c.

Reproducing this issue is simple as below:

1. Trigger hard reset and mount pstore. Will see console-ramoops
record in the mounted location which is the current log.

2. Trigger warm reset and mount pstore. Will see the current
console-ramoops record instead of previous record.

Fixes: b05c950698fe ("pstore/ram: Simplify ramoops_get_next_prz() arguments")
Signed-off-by: Sai Prakash Ranjan <saiprakash.ranjan@codeaurora.org>
Acked-by: Joel Fernandes (Google) <joel@joelfernandes.org>
[kees: dropped local variable usage]
Signed-off-by: Kees Cook <keescook@chromium.org>

authored by Sai Prakash Ranjan and committed by Kees Cook 6a4c9ab1 1c7fc5cb

Changed files
+1 -2
fs
pstore
+1 -2
fs/pstore/ram.c
··· 128 128 struct pstore_record *record) 129 129 { 130 130 struct persistent_ram_zone *prz; 131 - bool update = (record->type == PSTORE_TYPE_DMESG); 132 131 133 132 /* Give up if we never existed or have hit the end. */ 134 133 if (!przs) ··· 138 139 return NULL; 139 140 140 141 /* Update old/shadowed buffer. */ 141 - if (update) 142 + if (prz->type == PSTORE_TYPE_DMESG) 142 143 persistent_ram_save_old(prz); 143 144 144 145 if (!persistent_ram_old_size(prz))