From: Richard Weinberger <richard@nod.at>
To: Sheng Yong <shengyong1@huawei.com>,
computersforpeace@gmail.com, dwmw2@infradead.org
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH 1/2] mtd: nandsim: fix free of NULL pointer
Date: Wed, 17 Jun 2015 11:05:30 +0200 [thread overview]
Message-ID: <5581385A.6000609@nod.at> (raw)
In-Reply-To: <558137E9.8060707@huawei.com>
Am 17.06.2015 um 11:03 schrieb Sheng Yong:
>
>
> On 6/17/2015 4:48 PM, Richard Weinberger wrote:
>> Am 17.06.2015 um 10:45 schrieb Sheng Yong:
>>> 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 cb38f3d..33e4064 100644
>>> --- a/drivers/mtd/nand/nandsim.c
>>> +++ b/drivers/mtd/nand/nandsim.c
>>> @@ -646,7 +646,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);
>>
>> It is perfectly fine to free a NULL pointer.
> OK, then maybe the double free is not a serious problem, besides we just
> get a message "Trying to vfree() nonexistent vm area" or the like. But
> kmem_cache_destroy() will access ns->nand_pages_slab, and ns->nand_pages_slab
> is NULL. This will crash the kernel. :)
Please see my other may, I was wrong. :)
Thanks,
//richard
next prev parent reply other threads:[~2015-06-17 9:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-17 8:45 [PATCH 0/2] mtd: nandsim: fix error handling Sheng Yong
2015-06-17 8:45 ` [PATCH 1/2] mtd: nandsim: fix free of NULL pointer Sheng Yong
2015-06-17 8:48 ` Richard Weinberger
2015-06-17 9:00 ` Richard Weinberger
2015-06-17 9:03 ` Sheng Yong
2015-06-17 9:05 ` Richard Weinberger [this message]
2015-06-17 8:45 ` [PATCH 2/2] mtd: nandsim: fix double free Sheng Yong
2015-06-23 1:03 ` [PATCH 0/2] mtd: nandsim: fix error handling Sheng Yong
2015-06-23 6:26 ` Richard Weinberger
2015-06-24 0:53 ` Sheng Yong
2015-06-23 21:59 ` Brian Norris
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=5581385A.6000609@nod.at \
--to=richard@nod.at \
--cc=computersforpeace@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=shengyong1@huawei.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.