[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <v2gbd0d95d71005070247j1f615a65mcbd52b5b6474206e@mail.gmail.com>
Date: Fri, 7 May 2010 17:47:45 +0800
From: Steven Liu <lingjiujianke@...il.com>
To: nigel@...onice.net
Cc: Linus WALLEIJ <linus.walleij@...ricsson.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] Check kmalloc return value before use the buffer
Hi, guy,
the code in arch/arm/mach-u300/dummyspichip.c is
bigtxbuf_virtual = kmalloc(DMA_TEST_SIZE, GFP_KERNEL);
if (bigtxbuf_virtual == NULL) {
status = -ENOMEM;
goto out;
}
bigrxbuf_virtual = kmalloc(DMA_TEST_SIZE, GFP_KERNEL);
if kmalloc memory space for bigrxbuf_virtual is NULL, when it have
kmalloc DMA_TEST_SIZE memory space for bigtxbuf_virtual,so ,if kmalloc
memory for bigtxbuf_virtual success and kmalloc memory for
bigrxbuf_virtual faild,i think we must kfree bigtxbuf_virtual memory
best regards,
LiuQi
2010/5/7 Nigel Cunningham <nigel@...onice.net>:
> Hi.
>
> No commit comment?
>
> On 07/05/10 17:17, Steven Liu wrote:
>>
>> Signed-off-by: LiuQi<lingjiujianke@...il.com>
>> ---
>> arch/arm/mach-u300/dummyspichip.c | 5 +++++
>> 1 files changed, 5 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/mach-u300/dummyspichip.c
>> b/arch/arm/mach-u300/dummyspichip.c
>> index 5f55012..df19f9b 100644
>> --- a/arch/arm/mach-u300/dummyspichip.c
>> +++ b/arch/arm/mach-u300/dummyspichip.c
>> @@ -64,6 +64,11 @@ static ssize_t dummy_looptest(struct device *dev,
>> goto out;
>> }
>> bigrxbuf_virtual = kmalloc(DMA_TEST_SIZE, GFP_KERNEL);
>> + if (bigrxbuf_virtual == NULL) {
>> + status = -ENOMEM;
>> + kfree(bigtxbuf_virtual);
>
> Why kfree something you know is NULL?
>
> Regards,
>
> Nigel
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists