summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2019-12-30 11:48:10 -0800
committerKees Cook <keescook@chromium.org>2020-01-02 12:30:39 -0800
commit8df955a32a73315055e0cd187cbb1cea5820394b (patch)
tree51a54cdb8074c25a8a5aca178624e0542d649f7a /fs
parentd1eef1c619749b2a57e514a3fa67d9a516ffa919 (diff)
downloadlinux-stable-8df955a32a73315055e0cd187cbb1cea5820394b.tar.gz
linux-stable-8df955a32a73315055e0cd187cbb1cea5820394b.tar.bz2
linux-stable-8df955a32a73315055e0cd187cbb1cea5820394b.zip
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 <navid.emamdoost@gmail.com> Fixes: 1227daa43bce ("pstore/ram: Clarify resource reservation labels") Cc: stable@vger.kernel.org Link: https://lore.kernel.org/lkml/20191211191353.14385-1-navid.emamdoost@gmail.com Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/pstore/ram.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 8caff834f002..f753f3b6f88d 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -577,6 +577,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 +623,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;
}