Index: kernel/generic/src/proc/thread.c
===================================================================
--- kernel/generic/src/proc/thread.c	(revision c03ee1c304c982b593d8043411e6b003dd1c155a)
+++ kernel/generic/src/proc/thread.c	(revision 4680ef5eeda9925a3978a4a02f31a915dbdabe5f)
@@ -386,13 +386,4 @@
 		task_destroy(t->task);
 	
-	/*
-	 * If the thread had a userspace context, free up its kernel_uarg
-	 * structure.
-	 */
-	if (t->flags & THREAD_FLAG_USPACE) {
-		ASSERT(t->thread_arg);
-		free(t->thread_arg);
-	}
-
 	slab_free(thread_slab, t);
 }
@@ -683,5 +674,10 @@
 		return (unative_t) rc;
 
-	kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0);	
+	/*
+	 * In case of failure, kernel_uarg will be deallocated in this function.
+	 * In case of success, kernel_uarg will be freed in uinit().
+	 */
+	kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0);
+	
 	rc = copy_from_uspace(kernel_uarg, uspace_uarg, sizeof(uspace_arg_t));
 	if (rc != 0) {
