Index: uspace/lib/libblock/libblock.c
===================================================================
--- uspace/lib/libblock/libblock.c	(revision e27b89ad7a36cbdf96bb40b3057e485266d12200)
+++ uspace/lib/libblock/libblock.c	(revision 0712ff2bf49f40e0f98620ef8c03ac5be07df2a1)
@@ -345,5 +345,5 @@
 	link_t *l;
 	unsigned long key = boff;
-	int rc = EOK;
+	int rc;
 	
 	devcon = devcon_search(dev_handle);
@@ -355,4 +355,7 @@
 
 retry:
+	rc = EOK;
+	b = NULL;
+
 	fibril_mutex_lock(&cache->lock);
 	l = hash_table_find(&cache->block_hash, &key);
@@ -394,5 +397,9 @@
 			unsigned long temp_key;
 recycle:
-			assert(!list_empty(&cache->free_head));
+			if (list_empty(&cache->free_head)) {
+				fibril_mutex_unlock(&cache->lock);
+				rc = ENOMEM;
+				goto out;
+			}
 			l = cache->free_head.next;
 			b = list_get_instance(l, block_t, free_link);
@@ -477,4 +484,10 @@
 
 		fibril_mutex_unlock(&b->lock);
+	}
+out:
+	if ((rc != EOK) && b) {
+		assert(b->toxic);
+		(void) block_put(b);
+		b = NULL;
 	}
 	*block = b;
