mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@redhat.com>,
	Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
	Ingo Molnar <mingo@redhat.com>
Cc: Will Deacon <will.deacon@arm.com>, Mark Rutland <mark.rutland@arm.com>
Subject: [PATCH 1/3] perf: tools: Fix aliasing violation in zfree uses
Date: Wed, 15 Jan 2014 10:44:06 +0000	[thread overview]
Message-ID: <1389782648-4417-2-git-send-email-mark.rutland@arm.com> (raw)
In-Reply-To: <1389782648-4417-1-git-send-email-mark.rutland@arm.com>

Commit 74cf249d5cf7 (perf tools: Use zfree to help detect
use after free bugs) changed many uses of free to zfree, which
automatically clears the pointer. However, in a couple of places it
casts a const char** to void**, which the compiler doesn't like:

  cc1: warnings being treated as errors
  util/strlist.c: In function ‘str_node__delete’:
  util/strlist.c:42: error: dereferencing type-punned pointer will break strict-aliasing rules
  util/strlist.c:42: error: dereferencing type-punned pointer will break strict-aliasing rules
  make[1]: *** [util/strlist.o] Error 1

This patch fixes the issue by only throwing away the const, casting to char**
instead. This is more readily accepted by the compiler.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
---
 tools/perf/util/srcline.c | 4 ++--
 tools/perf/util/strlist.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
index 7e67879..f3e4bc5 100644
--- a/tools/perf/util/srcline.c
+++ b/tools/perf/util/srcline.c
@@ -129,7 +129,7 @@ static struct a2l_data *addr2line_init(const char *path)
 
 out:
 	if (a2l) {
-		zfree((void **)&a2l->input);
+		zfree((char **)&a2l->input);
 		free(a2l);
 	}
 	bfd_close(abfd);
@@ -140,7 +140,7 @@ static void addr2line_cleanup(struct a2l_data *a2l)
 {
 	if (a2l->abfd)
 		bfd_close(a2l->abfd);
-	zfree((void **)&a2l->input);
+	zfree((char **)&a2l->input);
 	zfree(&a2l->syms);
 	free(a2l);
 }
diff --git a/tools/perf/util/strlist.c b/tools/perf/util/strlist.c
index 61a90bf..71f9d10 100644
--- a/tools/perf/util/strlist.c
+++ b/tools/perf/util/strlist.c
@@ -39,7 +39,7 @@ out_delete:
 static void str_node__delete(struct str_node *snode, bool dupstr)
 {
 	if (dupstr)
-		zfree((void **)&snode->s);
+		zfree((char **)&snode->s);
 	free(snode);
 }
 
-- 
1.8.1.1


  reply	other threads:[~2014-01-15 10:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-15 10:44 [PATCH 0/3] Fix perf tool issues in tip/perf/core Mark Rutland
2014-01-15 10:44 ` Mark Rutland [this message]
2014-01-15 10:44 ` [PATCH 2/3] tools lib traceevent: fix pointer-integer size mismatch Mark Rutland
2014-01-15 18:14   ` Arnaldo Carvalho de Melo
2014-01-15 18:42     ` Jiri Olsa
2014-01-15 19:40     ` Steven Rostedt
2014-01-16 13:39   ` [tip:perf/core] " tip-bot for Mark Rutland
2014-01-15 10:44 ` [PATCH 3/3] perf: tools: fix cross building Mark Rutland
2014-01-16 13:38   ` [tip:perf/core] perf: tools: Fix " tip-bot for Mark Rutland

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=1389782648-4417-2-git-send-email-mark.rutland@arm.com \
    --to=mark.rutland@arm.com \
    --cc=acme@ghostprotocols.net \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=will.deacon@arm.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®