blob: 5c51a8c49524a13455e2d5e9943a4f4c11f4baa0 [file] [log] [blame]
From dc167940140f08def72fc2c177673f5fcc411e3b Mon Sep 17 00:00:00 2001
From: Kees Cook <keescook@chromium.org>
Date: Mon, 30 Dec 2019 11:48:10 -0800
Subject: [PATCH] pstore/ram: Fix error-path memory leak in
persistent_ram_new() callers
commit 8df955a32a73315055e0cd187cbb1cea5820394b upstream.
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>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index b345f8b6d255..5f3753664269 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -588,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--;
@@ -633,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;
}
--
2.7.4