lkml.org 
[lkml]   [2019]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] pstore/ram: Fix memory leak in persistent_ram_new
Date
In the implementation of persistent_ram_new(), if the allocation for prz
fails, "label" should be released as part of error handling. Release the
label via kfree().

Fixes: 8cf5aff89e59 ("staging: android: persistent_ram: Introduce persistent_ram_new()")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
fs/pstore/ram_core.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
index 8823f65888f0..7d2d86999211 100644
--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -568,6 +568,7 @@ struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
prz = kzalloc(sizeof(struct persistent_ram_zone), GFP_KERNEL);
if (!prz) {
pr_err("failed to allocate persistent ram zone\n");
+ kfree(label);
goto err;
}

--
2.17.1
\
 
 \ /
  Last update: 2019-12-11 20:16    [W:0.056 / U:0.488 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site