Index: kernel/generic/src/sysinfo/sysinfo.c
===================================================================
--- kernel/generic/src/sysinfo/sysinfo.c	(revision 80bfb601d828951693b11892603e3161b6736ea0)
+++ kernel/generic/src/sysinfo/sysinfo.c	(revision c3d4bb457c89cf2c85195cda220c37d624d7625f)
@@ -496,5 +496,4 @@
 		
 		unative_t val;
-		void *data;
 		size_t size;
 		
@@ -518,10 +517,6 @@
 			break;
 		case SYSINFO_VAL_FUNCTION_DATA:
-			data = cur->val.fn_data(cur, &size);
-			
-			/* N.B.: The generated binary data should be freed */
-			if (data != NULL)
-				free(data);
-			
+			/* N.B.: No data was actually returned (only a dry run) */
+			(void) cur->val.fn_data(cur, &size, true);
 			printf("+ %s (%" PRIs" bytes) [generated]\n", cur->name,
 			    size);
@@ -579,13 +574,16 @@
  * and sysinfo_lock held.
  *
- * @param name Sysinfo path.
- * @param root Root item of the sysinfo (sub)tree.
- *             If it is NULL then consider the global
- *             sysinfo tree.
+ * @param name    Sysinfo path.
+ * @param root    Root item of the sysinfo (sub)tree.
+ *                If it is NULL then consider the global
+ *                sysinfo tree.
+ * @param dry_run Do not actually get any generated
+ *                binary data, just calculate the size.
  *
  * @return Item value (constant or generated).
  *
  */
-static sysinfo_return_t sysinfo_get_item(const char *name, sysinfo_item_t **root)
+static sysinfo_return_t sysinfo_get_item(const char *name,
+    sysinfo_item_t **root, bool dry_run)
 {
 	if (root == NULL)
@@ -614,5 +612,6 @@
 			break;
 		case SYSINFO_VAL_FUNCTION_DATA:
-			ret.data.data = item->val.fn_data(item, &ret.data.size);
+			ret.data.data = item->val.fn_data(item, &ret.data.size,
+			    dry_run);
 			break;
 		}
@@ -635,9 +634,12 @@
  * (the last passed character must be null).
  *
- * @param ptr  Sysinfo path in the user address space.
- * @param size Size of the path string.
- *
- */
-static sysinfo_return_t sysinfo_get_item_uspace(void *ptr, size_t size)
+ * @param ptr     Sysinfo path in the user address space.
+ * @param size    Size of the path string.
+ * @param dry_run Do not actually get any generated
+ *                binary data, just calculate the size.
+ *
+ */
+static sysinfo_return_t sysinfo_get_item_uspace(void *ptr, size_t size,
+    bool dry_run)
 {
 	sysinfo_return_t ret;
@@ -652,5 +654,5 @@
 	if ((copy_from_uspace(path, ptr, size + 1) == 0)
 	    && (path[size] == 0))
-		ret = sysinfo_get_item(path, NULL);
+		ret = sysinfo_get_item(path, NULL, dry_run);
 	
 	free(path);
@@ -677,10 +679,9 @@
 	spinlock_lock(&sysinfo_lock);
 	
-	/* Get the item */
-	sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size);
-	
-	/* N.B.: The generated binary data should be freed */
-	if ((ret.tag == SYSINFO_VAL_FUNCTION_DATA) && (ret.data.data != NULL))
-		free(ret.data.data);
+	/* Get the item.
+	
+	   N.B.: There is no need to free any potential generated
+	   binary data since we request a dry run */
+	sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, true);
 	
 	/* Map generated value types to constant types
@@ -720,6 +721,9 @@
 	spinlock_lock(&sysinfo_lock);
 	
-	/* Get the item */
-	sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size);
+	/* Get the item.
+	
+	   N.B.: There is no need to free any potential generated
+	   binary data since we request a dry run */
+	sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, true);
 	int rc;
 	
@@ -730,8 +734,4 @@
 		rc = EINVAL;
 	
-	/* N.B.: The generated binary data should be freed */
-	if ((ret.tag == SYSINFO_VAL_FUNCTION_DATA) && (ret.data.data != NULL))
-		free(ret.data.data);
-	
 	spinlock_unlock(&sysinfo_lock);
 	interrupts_restore(ipl);
@@ -762,6 +762,9 @@
 	spinlock_lock(&sysinfo_lock);
 	
-	/* Get the item */
-	sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size);
+	/* Get the item.
+	
+	   N.B.: There is no need to free any potential generated
+	   binary data since we request a dry run */
+	sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, true);
 	int rc;
 	
@@ -773,8 +776,4 @@
 		rc = EINVAL;
 	
-	/* N.B.: The generated binary data should be freed */
-	if ((ret.tag == SYSINFO_VAL_FUNCTION_DATA) && (ret.data.data != NULL))
-		free(ret.data.data);
-	
 	spinlock_unlock(&sysinfo_lock);
 	interrupts_restore(ipl);
@@ -811,5 +810,5 @@
 	
 	/* Get the item */
-	sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size);
+	sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, false);
 	int rc;
 	
