Skip to content

Commit 8df955a

Browse files
committed
pstore/ram: Fix error-path memory leak in persistent_ram_new() callers
For callers that allocated a label for persistent_ram_new(), if the call fails, they must clean up the allocation. Suggested-by: Navid Emamdoost <[email protected]> Fixes: 1227daa ("pstore/ram: Clarify resource reservation labels") Cc: [email protected] Link: https://lore.kernel.org/lkml/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent d1eef1c commit 8df955a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/pstore/ram.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ static int ramoops_init_przs(const char *name,
577577
dev_err(dev, "failed to request %s mem region (0x%zx@0x%llx): %d\n",
578578
name, record_size,
579579
(unsigned long long)*paddr, err);
580+
kfree(label);
580581

581582
while (i > 0) {
582583
i--;
@@ -622,6 +623,7 @@ static int ramoops_init_prz(const char *name,
622623

623624
dev_err(dev, "failed to request %s mem region (0x%zx@0x%llx): %d\n",
624625
name, sz, (unsigned long long)*paddr, err);
626+
kfree(label);
625627
return err;
626628
}
627629

0 commit comments

Comments
 (0)