From: Steven Liu <lingjiujianke@gmail.com>
To: Linus WALLEIJ <linus.walleij@stericsson.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Check kmalloc return value before use the buffer
Date: Fri, 7 May 2010 15:16:34 +0800 [thread overview]
Message-ID: <q2jbd0d95d71005070016we6efdcb8n239bd786fe7369bc@mail.gmail.com> (raw)
In-Reply-To: <CEE6BB42CAD6E947908279175AF8470A025A68CE5C@EXDCVYMBSTM006.EQ1STM.local>
Oh,I think I have a mistake
Signed-off-by: root <root@T-bagwell.(none)>
---
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);
+ goto out;
+ }
/* Fill TXBUF with some happy pattern */
memset(bigtxbuf_virtual, 0xAA, DMA_TEST_SIZE);
--
1.6.0.3
what a bout this one, please?
Best regards!
2010/5/7 Linus WALLEIJ <linus.walleij@stericsson.com>:
> Hi Liu,
>
>> Hi,linus.walleij
>>
>> Check kmalloc return value before use the buffer
>>
>>
>> Signed-off-by: LiuQi <lingjiujianke@gmail.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 962f9de..4f2af7c 100644
>> --- a/arch/arm/mach-u300/dummyspichip.c
>> +++ b/arch/arm/mach-u300/dummyspichip.c
>> @@ -63,6 +63,11 @@ static ssize_t dummy_looptest(struct device *dev,
>> goto out;
>> }
>> bigrxbuf_virtual = kmalloc(DMA_TEST_SIZE, GFP_KERNEL);
>> + if (bigtxbuf_virtual == NULL) {
>> + status = -ENOMEM;
>> + kfree(bigtxbuf_virtual);
>
> kfree():ing NULL is OK, but you just checked it to be NULL so why?
>
>> + goto out;
>> + }
>>
>> /* Fill TXBUF with some happy pattern */
>> memset(bigtxbuf_virtual, 0xAA, DMA_TEST_SIZE);
>
> Otherwise the bug it fixes is good to fix.
>
> Yours,
> Linus Walleij
>
next prev parent reply other threads:[~2010-05-07 7:16 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-07 2:41 Steven Liu
2010-05-07 6:52 ` Linus WALLEIJ
2010-05-07 7:16 ` Steven Liu [this message]
2010-05-07 7:17 ` Steven Liu
2010-05-07 9:37 ` Nigel Cunningham
2010-05-07 9:37 ` Nigel Cunningham
2010-05-07 9:47 ` Steven Liu
2010-05-07 9:51 ` Nigel Cunningham
2010-05-07 18:57 ` Linus WALLEIJ
2010-05-08 1:27 ` Nigel Cunningham
2010-05-08 8:56 ` Steven Liu
2010-05-10 21:49 ` Andy Isaacson
2010-05-10 22:08 ` Nigel Cunningham
2010-05-07 9:50 ` Steven Liu
2010-05-07 9:52 ` Nigel Cunningham
2010-05-07 9:55 ` Steven Liu
2010-05-07 9:05 Steven Liu
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=q2jbd0d95d71005070016we6efdcb8n239bd786fe7369bc@mail.gmail.com \
--to=lingjiujianke@gmail.com \
--cc=linus.walleij@stericsson.com \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®