From: leo.yan@linaro.org (Leo Yan)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH RFC 1/4] coresight: tmc: check dump buffer is overflow
Date: Tue, 11 Apr 2017 17:10:26 +0800 [thread overview]
Message-ID: <1491901829-18477-2-git-send-email-leo.yan@linaro.org> (raw)
In-Reply-To: <1491901829-18477-1-git-send-email-leo.yan@linaro.org>
In the code dumping ETB buffer is terminated when read back value
0xFFFF_FFFF. This is not safe and introduce infinite looping for some
cases, e.g. when reset the CPU and read out ETB RAM.
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
drivers/hwtracing/coresight/coresight-tmc-etf.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c
index 3a1c181..6150dac 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-etf.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c
@@ -54,6 +54,13 @@ static void tmc_etb_dump_hw(struct tmc_drvdata *drvdata)
read_data = readl_relaxed(drvdata->base + TMC_RRD);
if (read_data == 0xFFFFFFFF)
return;
+
+ /* Check if allocated buffer is overflow */
+ if (drvdata->len >= drvdata->size) {
+ dev_info(drvdata->dev, "TMC dump overflow!\n");
+ return;
+ }
+
memcpy(bufp, &read_data, 4);
bufp += 4;
drvdata->len += 4;
--
2.7.4
next prev parent reply other threads:[~2017-04-11 9:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-11 9:10 [PATCH RFC 0/4] coresight: support dump ETB RAM Leo Yan
2017-04-11 9:10 ` Leo Yan [this message]
2017-04-11 9:10 ` [PATCH RFC 2/4] coresight: tmc: set read pointer before dump RAM Leo Yan
2017-04-11 11:25 ` Chunyan Zhang
2017-04-11 13:46 ` Leo Yan
2017-04-11 9:10 ` [PATCH RFC 3/4] coresight: tmc: dump RAM when device is disabled Leo Yan
2017-04-11 9:10 ` [PATCH RFC 4/4] coresight: tmc: dump RAM for panic Leo Yan
2017-04-20 17:45 ` [PATCH RFC 0/4] coresight: support dump ETB RAM Mathieu Poirier
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=1491901829-18477-2-git-send-email-leo.yan@linaro.org \
--to=leo.yan@linaro.org \
--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;
as well as URLs for NNTP newsgroup(s).