Date: Thu, 18 Aug 2011 07:01:33 -0400 (EDT)
From: Petr Holasek <pholasek@redhat.com>
To: linux-numa@vger.kernel.org

[PATCH] libnuma: checking of sucessful allocations in numademo

This patch is based on BZ 
https://bugzilla.redhat.com/show_bug.cgi?id=707138
where too big argument for numademo caused segfault.

Only simple check of returned pointer from numa_alloc*
calls was added.

Signed-off-by: Petr Holasek <pholasek@redhat.com>

--
---
 numademo.c |    7 +++++++
 1 file changed, 7 insertions(+)

Index: numactl-dev/numademo.c
===================================================================
--- numactl-dev.orig/numademo.c
+++ numactl-dev/numademo.c
@@ -156,6 +156,13 @@ void memtest(char *name, unsigned char *
 	int i;
 	char title[128], result[128];
 
+	if (!mem) {
+		fprintf(stderr,
+		"Failed to allocate %lu bytes of memory. Test \"%s\" exits.\n",
+			msize, name);
+		return;
+	}
+
 #ifdef HAVE_STREAM_LIB
 	if (thistest == STREAM) {
 		do_stream(name, mem);
