Skip to content

Commit

Permalink
Merge tag 'pstore-v5.5-rc6' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/git/kees/linux

Pull pstore fix from Kees Cook:
 "Cengiz Can forwarded a Coverity report about more problems with a rare
  pstore initialization error path, so the allocation lifetime was
  rearranged to avoid needing to share the kfree() responsibilities
  between caller and callee"

* tag 'pstore-v5.5-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  pstore/ram: Regularize prz label allocation lifetime
  • Loading branch information
Linus Torvalds committed Jan 10, 2020
2 parents 6d25ef7 + e163fdb commit bef1d88
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions fs/pstore/ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,12 +583,12 @@ static int ramoops_init_przs(const char *name,
prz_ar[i] = persistent_ram_new(*paddr, zone_sz, sig,
&cxt->ecc_info,
cxt->memtype, flags, label);
kfree(label);
if (IS_ERR(prz_ar[i])) {
err = PTR_ERR(prz_ar[i]);
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--;
Expand Down Expand Up @@ -629,12 +629,12 @@ static int ramoops_init_prz(const char *name,
label = kasprintf(GFP_KERNEL, "ramoops:%s", name);
*prz = persistent_ram_new(*paddr, sz, sig, &cxt->ecc_info,
cxt->memtype, PRZ_FLAG_ZAP_OLD, label);
kfree(label);
if (IS_ERR(*prz)) {
int err = PTR_ERR(*prz);

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;
}

Expand Down
2 changes: 1 addition & 1 deletion fs/pstore/ram_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
/* Initialize general buffer state. */
raw_spin_lock_init(&prz->buffer_lock);
prz->flags = flags;
prz->label = label;
prz->label = kstrdup(label, GFP_KERNEL);

ret = persistent_ram_buffer_map(start, size, prz, memtype);
if (ret)
Expand Down

0 comments on commit bef1d88

Please sign in to comment.