lkml.org 
[lkml]   [2016]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 22/46] mtd: nandsim: Cleanup destroy handlers
Date
From: Richard Weinberger <richard@nod.at>

Make sure that we free stuff only after it has been
initialized.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
drivers/mtd/nand/nandsim.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index bac3fde..816d795 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -770,6 +770,9 @@ static void ns_ram_destroy(struct nandsim *ns)
struct ns_ram_data *data = ns->backend_data;
int i;

+ if (!data)
+ return;
+
for (i = 0; i < ns->geom.pgnum; i++) {
if (data->pages[i].byte)
kmem_cache_free(data->nand_pages_slab,
@@ -784,15 +787,22 @@ static void ns_cachefile_destroy(struct nandsim *ns)
{
struct ns_cachefile_data *data = ns->backend_data;

+ if (!data)
+ return;
+
kfree(data->file_buf);
vfree(data->pages_written);
filp_close(data->cfile, NULL);
+ kfree(data);
}

static void ns_file_destroy(struct nandsim *ns)
{
struct ns_file_data *data = ns->backend_data;

+ if (!data)
+ return;
+
kfree(data->file_buf);
fput(data->file);
kfree(data);
--
2.8.3
\
 
 \ /
  Last update: 2016-09-22 23:58    [W:0.194 / U:0.292 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site