From: Vaishali Thakkar <vaishali.thakkar@oracle.com>
To: peterz@infradead.org
Cc: mingo@redhat.com, acme@kernel.org,
alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org,
Vaishali Thakkar <vaishali.thakkar@oracle.com>
Subject: [PATCH] perf tests: Do not use sizeof on pointer type
Date: Thu, 28 Apr 2016 22:16:57 +0530 [thread overview]
Message-ID: <1461862017-23358-1-git-send-email-vaishali.thakkar@oracle.com> (raw)
Using sizeof on a malloced pointer type will return the wordsize
which can often cause one to allocate a buffer much smaller than
it is needed. So, here do not use sizeof on pointer type.
Note that this has no effect on runtime because 'dsos' is a
pointer to a pointer.
Problem found using Coccinelle.
Signed-off-by: Vaishali Thakkar <vaishali.thakkar@oracle.com>
---
tools/perf/tests/dso-data.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c
index dc673ff..8cf0d9e 100644
--- a/tools/perf/tests/dso-data.c
+++ b/tools/perf/tests/dso-data.c
@@ -202,7 +202,7 @@ static int dsos__create(int cnt, int size)
{
int i;
- dsos = malloc(sizeof(dsos) * cnt);
+ dsos = malloc(sizeof(*dsos) * cnt);
TEST_ASSERT_VAL("failed to alloc dsos array", dsos);
for (i = 0; i < cnt; i++) {
--
2.1.4
next reply other threads:[~2016-04-28 16:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-28 16:46 Vaishali Thakkar [this message]
2016-04-28 18:36 ` Arnaldo Carvalho de Melo
2016-05-01 7:41 ` [tip:perf/core] " tip-bot for Vaishali Thakkar
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=1461862017-23358-1-git-send-email-vaishali.thakkar@oracle.com \
--to=vaishali.thakkar@oracle.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@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
all inboxes | Powered by JetHome®