1
0
Fork 0

pstore/ram: Fix error-path memory leak in persistent_ram_new() callers

commit 8df955a32a 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: 1227daa43b ("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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5.4-rM2-2.2.x-imx-squashed
Kees Cook 2019-12-30 11:48:10 -08:00 committed by Greg Kroah-Hartman
parent b578c35ed9
commit 50d18b655b
1 changed files with 2 additions and 0 deletions

View File

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