mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: He Kuang <hekuang@huawei.com>
To: <masami.hiramatsu.pt@hitachi.com>, <acme@kernel.org>,
	<a.p.zijlstra@chello.nl>, <mingo@redhat.com>,
	<namhyung@kernel.org>, <jolsa@kernel.org>
Cc: <wangnan0@huawei.com>, <linux-kernel@vger.kernel.org>,
	<alexei.starovoitov@gmail.com>, <hekuang@huawei.com>
Subject: [PATCH v2 2/2] perf probe: Add failure check when show variable range
Date: Wed, 1 Jul 2015 11:53:24 +0000	[thread overview]
Message-ID: <1435751604-145643-2-git-send-email-hekuang@huawei.com> (raw)
In-Reply-To: <1435751604-145643-1-git-send-email-hekuang@huawei.com>

Change improper type size_t to diffptr_t to make consistent with libdw
and handle error code.

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 tools/perf/util/dwarf-aux.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index 2cb4c82..7658fb4 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -965,7 +965,7 @@ static int die_get_var_innermost_scope(Dwarf_Die *sp_die, Dwarf_Die *vr_die,
 {
 	Dwarf_Die *scopes;
 	int count;
-	size_t offset = 0;
+	ptrdiff_t offset = 0;
 	Dwarf_Addr base;
 	Dwarf_Addr start, end;
 	Dwarf_Addr entry;
@@ -991,6 +991,7 @@ static int die_get_var_innermost_scope(Dwarf_Die *sp_die, Dwarf_Die *vr_die,
 
 	while ((offset = dwarf_ranges(&scopes[1], offset, &base,
 				&start, &end)) > 0) {
+
 		start -= entry;
 		end -= entry;
 
@@ -1004,6 +1005,11 @@ static int die_get_var_innermost_scope(Dwarf_Die *sp_die, Dwarf_Die *vr_die,
 		}
 	}
 
+	if (offset < 0) {
+		ret = -EINVAL;
+		goto out;
+	}
+
 	if (!first)
 		strbuf_addf(buf, "]>");
 
@@ -1029,7 +1035,7 @@ int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf)
 	Dwarf_Addr entry;
 	Dwarf_Op *op;
 	size_t nops;
-	size_t offset = 0;
+	ptrdiff_t offset = 0;
 	Dwarf_Attribute attr;
 	bool first = true;
 	const char *name;
@@ -1067,6 +1073,9 @@ int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf)
 		}
 	}
 
+	if (offset < 0)
+		return -EINVAL;
+
 	if (!first)
 		strbuf_addf(buf, "]>");
 
-- 
1.8.5.2


  reply	other threads:[~2015-07-01 11:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-01  9:05 [PATCH 1/4] perf record: Use %ld for long type sample counter He Kuang
2015-07-01  9:05 ` [PATCH 2/4] perf probe: Fix failure to probe online module He Kuang
2015-07-01 11:14   ` Masami Hiramatsu
2015-07-01  9:05 ` [PATCH 3/4] perf probe: Enable --range option according to libdw version He Kuang
2015-07-01 11:02   ` Masami Hiramatsu
2015-07-01  9:05 ` [PATCH 4/4] perf probe: Add failure check when show variable range He Kuang
2015-07-01 11:00   ` Masami Hiramatsu
2015-07-01 11:53     ` [PATCH v2 1/2] perf probe: Enable --range option according to libdw version He Kuang
2015-07-01 11:53       ` He Kuang [this message]
2015-07-01 12:00     ` [PATCH 4/4] perf probe: Add failure check when show variable range He Kuang

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=1435751604-145643-2-git-send-email-hekuang@huawei.com \
    --to=hekuang@huawei.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=alexei.starovoitov@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=wangnan0@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 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®