diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2020-01-03 03:39:51 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-01-03 03:39:51 +0300 |
commit | 278b14eb920322255bf5b831e2bcfc1bf5999036 (patch) | |
tree | 8715f86aed2fd47f754b1fc902921ac932719fbb /fs | |
parent | 74f1a299107b9e1a563831a4ba85f769ab577164 (diff) | |
parent | 9e5f1c19800b808a37fb9815a26d382132c26c3d (diff) | |
download | linux-278b14eb920322255bf5b831e2bcfc1bf5999036.tar.xz |
Merge tag 'pstore-v5.5-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull pstore bug fixes from Kees Cook:
- always reset circular buffer state when writing new dump (Aleksandr
Yashkin)
- fix rare error-path memory leak (Kees Cook)
* tag 'pstore-v5.5-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
pstore/ram: Write new dumps to start of recycled zones
pstore/ram: Fix error-path memory leak in persistent_ram_new() callers
Diffstat (limited to 'fs')
-rw-r--r-- | fs/pstore/ram.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 8caff834f002..487ee39b438a 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -407,6 +407,17 @@ static int notrace ramoops_pstore_write(struct pstore_record *record) prz = cxt->dprzs[cxt->dump_write_cnt]; + /* + * Since this is a new crash dump, we need to reset the buffer in + * case it still has an old dump present. Without this, the new dump + * will get appended, which would seriously confuse anything trying + * to check dump file contents. Specifically, ramoops_read_kmsg_hdr() + * expects to find a dump header in the beginning of buffer data, so + * we must to reset the buffer values, in order to ensure that the + * header will be written to the beginning of the buffer. + */ + persistent_ram_zap(prz); + /* Build header and append record contents. */ hlen = ramoops_write_kmsg_hdr(prz, record); if (!hlen) @@ -577,6 +588,7 @@ static int ramoops_init_przs(const char *name, dev_err(dev, "failed to request %s mem region (0x%zx@0x%llx): %d\n", name, record_size, (unsigned long long)*paddr, err); + kfree(label); while (i > 0) { i--; @@ -622,6 +634,7 @@ static int ramoops_init_prz(const char *name, dev_err(dev, "failed to request %s mem region (0x%zx@0x%llx): %d\n", name, sz, (unsigned long long)*paddr, err); + kfree(label); return err; } |