Index: generic/src/proc/thread.c
===================================================================
--- generic/src/proc/thread.c	(revision a3eeceb63abe66d5ad2d3892d18a91ad79b185fc)
+++ generic/src/proc/thread.c	(revision e09d68ab5aa5fe4f5aa0dde9fa751a6fb3d7f2a0)
@@ -96,4 +96,5 @@
 	thread_t *t = (thread_t *)obj;
 	pfn_t pfn;
+	int status;
 
 	spinlock_initialize(&t->lock, "thread_t_lock");
@@ -103,8 +104,8 @@
 	link_initialize(&t->threads_link);
 	
-	pfn = frame_alloc(ONE_FRAME, FRAME_KA | kmflags);
+	pfn = frame_alloc_rc(ONE_FRAME, FRAME_KA | kmflags,&status);
+	if (status)
+		return -1;
 	t->kstack = (__u8 *)PA2KA(PFN2ADDR(pfn));
-	if (!t->kstack)
-		return -1;
 
 	return 0;
@@ -230,4 +231,6 @@
 	
 	t = (thread_t *) slab_alloc(thread_slab, 0);
+	if (!t)
+		return NULL;
 	
 	/* Not needed, but good for debugging */
