Index: uspace/lib/ext4/libext4_balloc.c
===================================================================
--- uspace/lib/ext4/libext4_balloc.c	(revision 7689590c5b958af13470ce1a107cdcf2697d26b7)
+++ uspace/lib/ext4/libext4_balloc.c	(revision e63ce679c8d778483bbfdb5b4002d12e23106fc8)
@@ -33,5 +33,5 @@
 /**
  * @file	libext4_balloc.c
- * @brief	Block allocator.
+ * @brief	Physical block allocator.
  */
 
@@ -370,4 +370,5 @@
 	}
 
+	// No free block found yet
 	block_put(bitmap_block);
 	ext4_filesystem_put_block_group_ref(bg_ref);
Index: uspace/lib/ext4/libext4_directory_index.c
===================================================================
--- uspace/lib/ext4/libext4_directory_index.c	(revision 7689590c5b958af13470ce1a107cdcf2697d26b7)
+++ uspace/lib/ext4/libext4_directory_index.c	(revision e63ce679c8d778483bbfdb5b4002d12e23106fc8)
@@ -353,5 +353,5 @@
 	// Hardcoded number 2 means maximum height of index tree !!!
 	ext4_directory_dx_block_t dx_blocks[2];
-	ext4_directory_dx_block_t *dx_block;
+	ext4_directory_dx_block_t *dx_block, *tmp;
 	rc = ext4_directory_dx_get_leaf(&hinfo, fs, inode_ref->inode, root_block, &dx_block, dx_blocks);
 	if (rc != EOK) {
@@ -367,5 +367,5 @@
     	rc = ext4_filesystem_get_inode_data_block_index(fs, inode_ref->inode, leaf_block_idx, &leaf_block_addr);
     	if (rc != EOK) {
-    		return EXT4_ERR_BAD_DX_DIR;
+    		goto cleanup;
     	}
 
@@ -373,10 +373,9 @@
 		rc = block_get(&leaf_block, fs->device, leaf_block_addr, BLOCK_FLAGS_NONE);
 		if (rc != EOK) {
-			return EXT4_ERR_BAD_DX_DIR;
+			goto cleanup;
 		}
 
 		ext4_directory_entry_ll_t *res_dentry;
 		rc = ext4_directory_find_in_block(leaf_block, fs->superblock, name_len, name, &res_dentry);
-
 
 		// Found => return it
@@ -387,16 +386,14 @@
 		}
 
+		// Not found, leave untouched
 		block_put(leaf_block);
 
-		// ERROR - corrupted index
-		if (rc == -1) {
-			// TODO cleanup
-			return EXT4_ERR_BAD_DX_DIR;
+		if (rc != ENOENT) {
+			goto cleanup;
 		}
 
 		rc = ext4_directory_dx_next_block(fs, inode_ref->inode, hinfo.hash, dx_block, &dx_blocks[0]);
 		if (rc < 0) {
-			// TODO cleanup
-			return EXT4_ERR_BAD_DX_DIR;
+			goto cleanup;
 		}
 
@@ -404,4 +401,13 @@
 
 	return ENOENT;
+
+cleanup:
+
+	tmp = dx_blocks;
+	while (tmp <= dx_block) {
+		block_put(tmp->block);
+		++tmp;
+	}
+	return rc;
 }
 
@@ -605,5 +611,5 @@
 {
 	int rc = EOK;
-	int rc2;
+	int rc2 = EOK;
 
 	// get direct block 0 (index root)
@@ -630,9 +636,9 @@
 	// Hardcoded number 2 means maximum height of index tree !!!
 	ext4_directory_dx_block_t dx_blocks[2];
-	ext4_directory_dx_block_t *dx_block;
+	ext4_directory_dx_block_t *dx_block, *dx_it;
 	rc = ext4_directory_dx_get_leaf(&hinfo, fs, parent->inode, root_block, &dx_block, dx_blocks);
 	if (rc != EOK) {
-		block_put(root_block);
-		return EXT4_ERR_BAD_DX_DIR;
+		rc = EXT4_ERR_BAD_DX_DIR;
+		goto release_index;
 	}
 
@@ -643,5 +649,5 @@
    	rc = ext4_filesystem_get_inode_data_block_index(fs, parent->inode, leaf_block_idx, &leaf_block_addr);
    	if (rc != EOK) {
-   		return EXT4_ERR_BAD_DX_DIR;
+   		goto release_index;
    	}
 
@@ -650,11 +656,10 @@
    	rc = block_get(&target_block, fs->device, leaf_block_addr, BLOCK_FLAGS_NONE);
    	if (rc != EOK) {
-   		return EXT4_ERR_BAD_DX_DIR;
+   		goto release_index;
    	}
 
    	rc = ext4_directory_try_insert_entry(fs->superblock, target_block, child, name, name_len);
    	if (rc == EOK) {
-   		goto cleanup;
-
+   		goto release_target_index;
    	}
 
@@ -679,7 +684,6 @@
 		if ((levels > 0) && (root_limit == root_count)) {
 			EXT4FS_DBG("Directory index is full");
-
-			// ENOSPC - cleanup !!!
-			return ENOSPC;
+			rc = ENOSPC;
+			goto release_target_index;
 		}
 
@@ -688,5 +692,5 @@
 		rc =  ext4_directory_append_block(fs, parent, &new_fblock, &new_iblock);
 		if (rc != EOK) {
-			goto cleanup;
+			goto release_target_index;
 		}
 
@@ -695,5 +699,5 @@
 		rc = block_get(&new_block, fs->device, new_fblock, BLOCK_FLAGS_NOREAD);
 		if (rc != EOK) {
-			goto cleanup;
+			goto release_target_index;
 		}
 
@@ -772,5 +776,6 @@
 	rc = ext4_directory_dx_split_data(fs, parent, &hinfo, target_block, dx_block, &new_block);
 	if (rc != EOK) {
-		// TODO error
+		rc2 = rc;
+		goto release_target_index;
 	}
 
@@ -788,4 +793,5 @@
 
 
+// TODO check rc handling
 terminate:
 	rc = block_put(new_block);
@@ -795,5 +801,5 @@
 
 
-cleanup:
+release_target_index:
 
 	rc2 = rc;
@@ -804,5 +810,6 @@
 	}
 
-	ext4_directory_dx_block_t *dx_it = dx_blocks;
+release_index:
+	dx_it = dx_blocks;
 
 	while (dx_it <= dx_block) {
Index: uspace/lib/ext4/libext4_filesystem.c
===================================================================
--- uspace/lib/ext4/libext4_filesystem.c	(revision 7689590c5b958af13470ce1a107cdcf2697d26b7)
+++ uspace/lib/ext4/libext4_filesystem.c	(revision e63ce679c8d778483bbfdb5b4002d12e23106fc8)
@@ -33,5 +33,5 @@
 /**
  * @file	libext4_filesystem.c
- * @brief	TODO
+ * @brief	More complex filesystem operations.
  */
 
@@ -348,5 +348,5 @@
 		rc = block_get(&block, fs->device, fblock, BLOCK_FLAGS_NONE);
 		if (rc != EOK) {
-			// TODO error
+			return rc;
 		}
 
@@ -358,5 +358,6 @@
 				rc = ext4_balloc_free_block(fs, inode_ref, ind_block);
 				if (rc != EOK) {
-					// TODO error
+					block_put(block);
+					return rc;
 				}
 			}
@@ -366,5 +367,5 @@
 		rc = ext4_balloc_free_block(fs, inode_ref, fblock);
 		if (rc != EOK) {
-			// TODO error
+			return rc;
 		}
 
@@ -379,5 +380,5 @@
 		rc = block_get(&block, fs->device, fblock, BLOCK_FLAGS_NONE);
 		if (rc != EOK) {
-			// TODO error
+			return rc;
 		}
 
@@ -389,5 +390,6 @@
 				rc = block_get(&subblock, fs->device, ind_block, BLOCK_FLAGS_NONE);
 				if (rc != EOK) {
-					// TODO error
+					block_put(block);
+					return rc;
 				}
 
@@ -399,5 +401,7 @@
 						rc = ext4_balloc_free_block(fs, inode_ref, ind_subblock);
 						if (rc != EOK) {
-							// TODO error
+							block_put(subblock);
+							block_put(block);
+							return rc;
 						}
 					}
@@ -410,5 +414,6 @@
 			rc = ext4_balloc_free_block(fs, inode_ref, ind_block);
 			if (rc != EOK) {
-				// TODO error
+				block_put(block);
+				return rc;
 			}
 
@@ -419,5 +424,5 @@
 		rc = ext4_balloc_free_block(fs, inode_ref, fblock);
 		if (rc != EOK) {
-			// TODO error
+			return rc;
 		}
 
@@ -613,6 +618,4 @@
 	}
 
-
-
 	uint32_t block_size = ext4_superblock_get_block_size(fs->superblock);
 
@@ -628,6 +631,5 @@
 		rc = ext4_balloc_alloc_block(fs, inode_ref, &new_block_addr);
 		if (rc != EOK) {
-			// TODO error
-			EXT4FS_DBG("error in allocation");
+			return rc;
 		}
 
@@ -638,6 +640,6 @@
 		rc = block_get(&new_block, fs->device, new_block_addr, BLOCK_FLAGS_NOREAD);
 		if (rc != EOK) {
-			EXT4FS_DBG("block load error");
-			// TODO error
+			ext4_balloc_free_block(fs, inode_ref, new_block_addr);
+			return rc;
 		}
 
@@ -647,8 +649,6 @@
 		rc = block_put(new_block);
 		if (rc != EOK) {
-			EXT4FS_DBG("block put error");
-		}
-
-//		EXT4FS_DBG("allocated indirect block for level \%u, during setting iblock \%u", level, (uint32_t)iblock);
+			return rc;
+		}
 
 		current_block = new_block_addr;
@@ -670,15 +670,14 @@
 			rc = ext4_balloc_alloc_block(fs, inode_ref, &new_block_addr);
 			if (rc != EOK) {
-				// TODO error
-				EXT4FS_DBG("allocation error");
+				block_put(block);
+				return rc;
 			}
 
 			rc = block_get(&new_block, fs->device, new_block_addr, BLOCK_FLAGS_NOREAD);
 			if (rc != EOK) {
-				// TODO error
-
-				EXT4FS_DBG("BBB: error block loading");
-
+				block_put(block);
+				return rc;
 			}
+
 			memset(new_block->data, 0, block_size);
 			new_block->dirty = true;
@@ -686,5 +685,6 @@
 			rc = block_put(new_block);
 			if (rc != EOK) {
-				EXT4FS_DBG("BBB: error indirect block saving");
+				block_put(block);
+				return rc;
 			}
 
Index: uspace/srv/fs/ext4fs/ext4fs_ops.c
===================================================================
--- uspace/srv/fs/ext4fs/ext4fs_ops.c	(revision 7689590c5b958af13470ce1a107cdcf2697d26b7)
+++ uspace/srv/fs/ext4fs/ext4fs_ops.c	(revision e63ce679c8d778483bbfdb5b4002d12e23106fc8)
@@ -1092,7 +1092,6 @@
 	rc = ext4_filesystem_get_inode_data_block_index(fs, inode_ref->inode, iblock, &fblock);
 	if (rc != EOK) {
-		// TODO error
 		ext4fs_node_put(fn);
-		EXT4FS_DBG("error loading block addr");
+		async_answer_0(callid, rc);
 		return rc;
 	}
