diff options
author | Vaishali Thakkar <vaishali.thakkar@oracle.com> | 2016-04-28 12:46:57 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-04-28 14:37:52 -0400 |
commit | ca7ce82a280a65c377c24c95c29b1dec6e80b428 (patch) | |
tree | 7ae35a11de58738aa07ae82f778b2373738db126 /tools/perf | |
parent | a30e6259b5e31e8d2b40f3b0099d98a6ebe0e360 (diff) |
perf tests: Do not use sizeof on pointer type
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>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1461862017-23358-1-git-send-email-vaishali.thakkar@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/tests/dso-data.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c index dc673ff7c437..8cf0d9e189a8 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) | |||
202 | { | 202 | { |
203 | int i; | 203 | int i; |
204 | 204 | ||
205 | dsos = malloc(sizeof(dsos) * cnt); | 205 | dsos = malloc(sizeof(*dsos) * cnt); |
206 | TEST_ASSERT_VAL("failed to alloc dsos array", dsos); | 206 | TEST_ASSERT_VAL("failed to alloc dsos array", dsos); |
207 | 207 | ||
208 | for (i = 0; i < cnt; i++) { | 208 | for (i = 0; i < cnt; i++) { |