Skip to content

Commit

Permalink
pstore/ram: Fix console ramoops to show the previous boot logs
Browse files Browse the repository at this point in the history
commit b05c950 ("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: b05c950 ("pstore/ram: Simplify ramoops_get_next_prz() arguments")
Signed-off-by: Sai Prakash Ranjan <[email protected]>
Acked-by: Joel Fernandes (Google) <[email protected]>
[kees: dropped local variable usage]
Signed-off-by: Kees Cook <[email protected]>
  • Loading branch information
Sai Prakash Ranjan authored and kees committed Jan 17, 2019
1 parent 1c7fc5c commit 6a4c9ab
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions fs/pstore/ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], int id,
struct pstore_record *record)
{
struct persistent_ram_zone *prz;
bool update = (record->type == PSTORE_TYPE_DMESG);

/* Give up if we never existed or have hit the end. */
if (!przs)
Expand All @@ -139,7 +138,7 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], int id,
return NULL;

/* Update old/shadowed buffer. */
if (update)
if (prz->type == PSTORE_TYPE_DMESG)
persistent_ram_save_old(prz);

if (!persistent_ram_old_size(prz))
Expand Down

0 comments on commit 6a4c9ab

Please sign in to comment.