Index: uspace/lib/c/generic/stats.c
===================================================================
--- uspace/lib/c/generic/stats.c	(revision 192a0063ea6b8b9ff643fa0049ca8886e11e8a37)
+++ uspace/lib/c/generic/stats.c	(revision ba5ab0911b1cbe87ab32ec0e395bfb35e9d19df4)
@@ -36,8 +36,8 @@
 #include <stats.h>
 #include <sysinfo.h>
-#include <assert.h>
 #include <errno.h>
 #include <stdio.h>
 #include <inttypes.h>
+#include <malloc.h>
 
 #define SYSINFO_STATS_MAX_PATH  64
@@ -71,5 +71,10 @@
 	    (stats_cpu_t *) sysinfo_get_data("system.cpus", &size);
 	
-	assert((size % sizeof(stats_cpu_t)) == 0);
+	if ((size % sizeof(stats_cpu_t)) != 0) {
+		if (stats_cpus != NULL)
+			free(stats_cpus);
+		*count = 0;
+		return NULL;
+	}
 	
 	*count = size / sizeof(stats_cpu_t);
@@ -91,5 +96,9 @@
 	    (stats_physmem_t *) sysinfo_get_data("system.physmem", &size);
 	
-	assert((size == sizeof(stats_physmem_t)) || (size == 0));
+	if (size != sizeof(stats_physmem_t)) {
+		if (stats_physmem != NULL)
+			free(stats_physmem);
+		return NULL;
+	}
 	
 	return stats_physmem;
@@ -111,5 +120,10 @@
 	    (stats_task_t *) sysinfo_get_data("system.tasks", &size);
 	
-	assert((size % sizeof(stats_task_t)) == 0);
+	if ((size % sizeof(stats_task_t)) != 0) {
+		if (stats_tasks != NULL)
+			free(stats_tasks);
+		*count = 0;
+		return NULL;
+	}
 	
 	*count = size / sizeof(stats_task_t);
@@ -135,5 +149,9 @@
 	    (stats_task_t *) sysinfo_get_data(name, &size);
 	
-	assert((size == sizeof(stats_task_t)) || (size == 0));
+	if (size != sizeof(stats_task_t)) {
+		if (stats_task != NULL)
+			free(stats_task);
+		return NULL;
+	}
 	
 	return stats_task;
@@ -155,5 +173,10 @@
 	    (stats_thread_t *) sysinfo_get_data("system.threads", &size);
 	
-	assert((size % sizeof(stats_thread_t)) == 0);
+	if ((size % sizeof(stats_thread_t)) != 0) {
+		if (stats_threads != NULL)
+			free(stats_threads);
+		*count = 0;
+		return NULL;
+	}
 	
 	*count = size / sizeof(stats_thread_t);
@@ -179,5 +202,9 @@
 	    (stats_thread_t *) sysinfo_get_data(name, &size);
 	
-	assert((size == sizeof(stats_thread_t)) || (size == 0));
+	if (size != sizeof(stats_thread_t)) {
+		if (stats_thread != NULL)
+			free(stats_thread);
+		return NULL;
+	}
 	
 	return stats_thread;
@@ -199,5 +226,10 @@
 	    (stats_exc_t *) sysinfo_get_data("system.exceptions", &size);
 	
-	assert((size % sizeof(stats_exc_t)) == 0);
+	if ((size % sizeof(stats_exc_t)) != 0) {
+		if (stats_exceptions != NULL)
+			free(stats_exceptions);
+		*count = 0;
+		return NULL;
+	}
 	
 	*count = size / sizeof(stats_exc_t);
@@ -217,5 +249,5 @@
 {
 	char name[SYSINFO_STATS_MAX_PATH];
-	snprintf(name, SYSINFO_STATS_MAX_PATH, "system.exceptionss.%u", excn);
+	snprintf(name, SYSINFO_STATS_MAX_PATH, "system.exceptions.%u", excn);
 	
 	size_t size = 0;
@@ -223,5 +255,9 @@
 	    (stats_exc_t *) sysinfo_get_data(name, &size);
 	
-	assert((size == sizeof(stats_exc_t)) || (size == 0));
+	if (size != sizeof(stats_exc_t)) {
+		if (stats_exception != NULL)
+			free(stats_exception);
+		return NULL;
+	}
 	
 	return stats_exception;
@@ -243,5 +279,10 @@
 	    (load_t *) sysinfo_get_data("system.load", &size);
 	
-	assert((size % sizeof(load_t)) == 0);
+	if ((size % sizeof(load_t)) != 0) {
+		if (load != NULL)
+			free(load);
+		*count = 0;
+		return NULL;
+	}
 	
 	*count = size / sizeof(load_t);
Index: uspace/lib/c/generic/sysinfo.c
===================================================================
--- uspace/lib/c/generic/sysinfo.c	(revision 192a0063ea6b8b9ff643fa0049ca8886e11e8a37)
+++ uspace/lib/c/generic/sysinfo.c	(revision ba5ab0911b1cbe87ab32ec0e395bfb35e9d19df4)
@@ -96,42 +96,38 @@
 void *sysinfo_get_data(const char *path, size_t *size)
 {
-	/* The binary data size might change during time.
-	   Unfortunatelly we cannot allocate the buffer
-	   and transfer the data as a single atomic operation.
+	/*
+	 * The binary data size might change during time.
+	 * Unfortunatelly we cannot allocate the buffer
+	 * and transfer the data as a single atomic operation.
+	 */
 	
-	   Let's hope that the number of iterations is bounded
-	   in common cases. */
-	
-	void *data = NULL;
-	
-	while (true) {
-		/* Get the binary data size */
-		int ret = sysinfo_get_data_size(path, size);
-		if ((ret != EOK) || (size == 0)) {
-			/* Not a binary data item
-			   or an empty item */
-			break;
-		}
-		
-		data = realloc(data, *size);
-		if (data == NULL)
-			break;
-		
-		/* Get the data */
-		ret = __SYSCALL4(SYS_SYSINFO_GET_DATA, (sysarg_t) path,
-		    (sysarg_t) str_size(path), (sysarg_t) data, (sysarg_t) *size);
-		if (ret == EOK)
-			return data;
-		
-		if (ret != ENOMEM) {
-			/* The failure to get the data was not caused
-			   by wrong buffer size */
-			break;
-		}
+	/* Get the binary data size */
+	int ret = sysinfo_get_data_size(path, size);
+	if ((ret != EOK) || (size == 0)) {
+		/*
+		 * Not a binary data item
+		 * or an empty item.
+		 */
+		*size = 0;
+		return NULL;
 	}
 	
-	if (data != NULL)
-		free(data);
+	void *data = malloc(*size);
+	if (data == NULL) {
+		*size = 0;
+		return NULL;
+	}
 	
+	/* Get the data */
+	size_t sz;
+	ret = __SYSCALL5(SYS_SYSINFO_GET_DATA, (sysarg_t) path,
+	    (sysarg_t) str_size(path), (sysarg_t) data, (sysarg_t) *size,
+	    (sysarg_t) &sz);
+	if (ret == EOK) {
+		*size = sz;
+		return data;
+	}
+	
+	free(data);
 	*size = 0;
 	return NULL;
