Skip to contentSkip to conversation

perf bench: fix memory allocation fail check in mem{set,cpy} workloads

PATCH In review Kirill A. Shutemov 3 participants 3 messages Jun 6, 2013 – Jul 12, 2013 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf bench: fix memory allocation fail check in mem{set,cpy} workloads

From: "Kirill A. Shutemov" <[email protected]>

Addresses of allocated memory areas saved to '*src' and '*dst', so we need to check them for NULL, not 'src' and 'dst'.

---
 tools/perf/bench/mem-memcpy.c |    4 ++--
 tools/perf/bench/mem-memset.c |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
tools/perf/bench/mem-memcpy.c +2 -2
index 93c83e3..25fd3f1 100644
@@ -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");
 }
 
tools/perf/bench/mem-memset.c +1 -1
index c6e4bc5..4a2f120 100644
@@ -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");
 }
 
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw

Hi Kirill,

At Thu, 6 Jun 2013 14:35:03 +0300,

Quoted 5 lines · Kirill A. Shutemov

From: "Kirill A. Shutemov" <[email protected]>

Addresses of allocated memory areas saved to '*src' and '*dst', so we need to check them for NULL, not 'src' and 'dst'.

Thanks for your fix, this is my mistake.

Quoted 46 lines
---
 tools/perf/bench/mem-memcpy.c |    4 ++--
 tools/perf/bench/mem-memset.c |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
tools/perf/bench/mem-memcpy.c +2 -2
index 93c83e3..25fd3f1 100644
@@ -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");
 }
 
tools/perf/bench/mem-memset.c +1 -1
index c6e4bc5..4a2f120 100644
@@ -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");
 }
 
Signature · 7 lines
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#2 lore raw

[tip:perf/urgent] perf bench: Fix memory allocation fail check in mem{set,cpy} workloads

In reply to Kirill A. Shutemov
perf bench: Fix memory allocation fail check in mem{set,cpy} workloads
Commit-ID:  13966721a11f4a2ba8038191e48083b5f31822bb
Gitweb:     http://git.kernel.org/tip/13966721a11f4a2ba8038191e48083b5f31822bb
Author:     Kirill A. Shutemov <[email protected]>
AuthorDate: Thu, 6 Jun 2013 14:35:03 +0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 8 Jul 2013 17:35:40 -0300

perf bench: Fix memory allocation fail check in mem{set,cpy} workloads

Addresses of allocated memory areas saved to '*src' and '*dst', so we need to check them for NULL, not 'src' and 'dst'.

---
 tools/perf/bench/mem-memcpy.c | 4 ++--
 tools/perf/bench/mem-memset.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
tools/perf/bench/mem-memcpy.c +2 -2
index 93c83e3..25fd3f1 100644
@@ -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");
 }
 
tools/perf/bench/mem-memset.c +1 -1
index c6e4bc5..4a2f120 100644
@@ -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");
 }