Skip to content

Commit

Permalink
perf bench: Fix memory allocation fail check in mem{set,cpy} workloads
Browse files Browse the repository at this point in the history
Addresses of allocated memory areas saved to '*src' and '*dst', so we
need to check them for NULL, not 'src' and 'dst'.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Cc: Hitoshi Mitake <h.mitake@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1370518503-4230-1-git-send-email-kirill.shutemov@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Kirill A. Shutemov authored and Arnaldo Carvalho de Melo committed Jul 8, 2013
1 parent 107de37 commit 1396672
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tools/perf/bench/mem-memcpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ static double timeval2double(struct timeval *ts)
static void alloc_mem(void **dst, void **src, size_t length)
{
*dst = zalloc(length);
if (!dst)
if (!*dst)
die("memory allocation failed - maybe length is too large?\n");

*src = zalloc(length);
if (!src)
if (!*src)
die("memory allocation failed - maybe length is too large?\n");
}

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/bench/mem-memset.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static double timeval2double(struct timeval *ts)
static void alloc_mem(void **dst, size_t length)
{
*dst = zalloc(length);
if (!dst)
if (!*dst)
die("memory allocation failed - maybe length is too large?\n");
}

Expand Down

0 comments on commit 1396672

Please sign in to comment.