From: Sheng Yong <shengyong1@huawei.com>
To: <computersforpeace@gmail.com>, <dwmw2@infradead.org>
Cc: richard@nod.at, linux-mtd@lists.infradead.org
Subject: [PATCH V2 1/2] mtd: nandsim: fix free of NULL pointer
Date: Thu, 25 Jun 2015 00:46:48 +0000 [thread overview]
Message-ID: <1435193209-54305-2-git-send-email-shengyong1@huawei.com> (raw)
In-Reply-To: <1435193209-54305-1-git-send-email-shengyong1@huawei.com>
If allocating ns->nand_pages_slab fails, do not try to destroy it when
cleaning up nandsim resources.
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
---
drivers/mtd/nand/nandsim.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index 52c0c1a..6a74f62 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -649,7 +649,8 @@ static void free_device(struct nandsim *ns)
kmem_cache_free(ns->nand_pages_slab,
ns->pages[i].byte);
}
- kmem_cache_destroy(ns->nand_pages_slab);
+ if (ns->nand_pages_slab)
+ kmem_cache_destroy(ns->nand_pages_slab);
vfree(ns->pages);
}
}
--
1.8.3.4
next prev parent reply other threads:[~2015-06-25 0:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-25 0:46 [PATCH V2 0/2] mtd: nandsim: fix error handling Sheng Yong
2015-06-25 0:46 ` Sheng Yong [this message]
2015-06-25 0:46 ` [PATCH V2 2/2] mtd: nandsim: fix double free Sheng Yong
2015-06-25 1:24 ` [PATCH V2 0/2] mtd: nandsim: fix error handling Brian Norris
2015-06-25 1:53 ` Sheng Yong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1435193209-54305-2-git-send-email-shengyong1@huawei.com \
--to=shengyong1@huawei.com \
--cc=computersforpeace@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox