From: gang.chen@asianux.com (Chen Gang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM:kernel checking failure after call vmalloc
Date: Wed, 30 Jan 2013 12:13:53 +0800 [thread overview]
Message-ID: <51089E01.9020009@asianux.com> (raw)
need checking failure after call vmalloc.
if fail:
need return fail code (-ENOMEM, long will be signed cast to int)
also need call etb_lock(t) to lock again.
better to let vmalloc code above etb_writel(... ETBR_READADDR).
Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
arch/arm/kernel/etm.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/arch/arm/kernel/etm.c b/arch/arm/kernel/etm.c
index 9b6de8c..fbe51a3 100644
--- a/arch/arm/kernel/etm.c
+++ b/arch/arm/kernel/etm.c
@@ -287,14 +287,20 @@ static ssize_t etb_read(struct file *file, char __user *data,
etb_unlock(t);
total = etb_getdatalen(t);
+ length = min(total * 4, (int)len);
+
+ buf = vmalloc(length);
+ if (!buf) {
+ etb_lock(t);
+ length = -ENOMEM;
+ goto out;
+ }
+
if (total == t->etb_bufsz)
first = etb_readl(t, ETBR_WRITEADDR);
etb_writel(t, first, ETBR_READADDR);
- length = min(total * 4, (int)len);
- buf = vmalloc(length);
-
dev_dbg(t->dev, "ETB buffer length: %d\n", total);
dev_dbg(t->dev, "ETB status reg: %x\n", etb_readl(t, ETBR_STATUS));
for (i = 0; i < length / 4; i++)
--
1.7.10.4
reply other threads:[~2013-01-30 4:13 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=51089E01.9020009@asianux.com \
--to=gang.chen@asianux.com \
--cc=linux-arm-kernel@lists.infradead.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