Index: uspace/lib/ext4/libext4_extent.c
===================================================================
--- uspace/lib/ext4/libext4_extent.c	(revision 1196df68031af4bfbb2484851bef728c95910e57)
+++ uspace/lib/ext4/libext4_extent.c	(revision 6f413125cdf3989b155ab364f234251b7bc4f125)
@@ -302,7 +302,5 @@
 		rc = block_get(&block, inode_ref->fs->device, fblock, BLOCK_FLAGS_NONE);
 		if (rc != EOK) {
-			// TODO cleanup
-			EXT4FS_DBG("ERRRR");
-			return rc;
+			goto cleanup;
 		}
 
@@ -325,4 +323,19 @@
 
 	return EOK;
+
+cleanup:
+	// Put loaded blocks
+	// From 1 -> 0 is a block with inode data
+	for (uint16_t i = 1; i < tmp_path->depth; ++i) {
+		if (tmp_path[i].block) {
+			block_put(tmp_path[i].block);
+		}
+	}
+
+	// Destroy temporary data structure
+	free(tmp_path);
+
+	return rc;
+
 }
 
@@ -400,5 +413,5 @@
 		uint32_t iblock_from)
 {
-	int rc;
+	int rc = EOK;
 
 	// Find the first extent to modify
@@ -429,7 +442,5 @@
 	rc = ext4_balloc_free_blocks(inode_ref, first_fblock, delete_count);
 	if (rc != EOK) {
-		// TODO goto cleanup
-		EXT4FS_DBG("ERROR");
-		return rc;
+		goto cleanup;
 	}
 
@@ -454,7 +465,5 @@
 		rc = ext4_balloc_free_blocks(inode_ref, first_fblock, delete_count);
 		if (rc != EOK) {
-			// TODO goto cleanup
-			EXT4FS_DBG("ERROR");
-			return rc;
+			goto cleanup;
 		}
 
@@ -472,7 +481,5 @@
 		rc = ext4_balloc_free_block(inode_ref, path_ptr->block->lba);
 		if (rc != EOK) {
-			EXT4FS_DBG("ERROR");
-			// TODO goto cleanup
-			return rc;
+			goto cleanup;
 		}
 		check_tree = true;
@@ -497,7 +504,5 @@
 			rc = ext4_extent_release_branch(inode_ref, index);
 			if (rc != EOK) {
-				EXT4FS_DBG("ERR");
-				// TODO goto cleanup
-				return rc;
+				goto cleanup;
 			}
 			++index;
@@ -511,7 +516,5 @@
 			rc = ext4_balloc_free_block(inode_ref, path_ptr->block->lba);
 			if (rc != EOK) {
-				EXT4FS_DBG("ERROR");
-				// TODO goto cleanup
-				return rc;
+				goto cleanup;
 			}
 			check_tree = true;
@@ -524,10 +527,8 @@
 
 
-	// Finish
-	uint16_t depth = path->depth;
-
+cleanup:
 	// Put loaded blocks
 	// From 1 -> 0 is a block with inode data
-	for (uint16_t i = 1; i < depth; ++i) {
+	for (uint16_t i = 1; i < path->depth; ++i) {
 		if (path[i].block) {
 			block_put(path[i].block);
@@ -538,5 +539,5 @@
 	free(path);
 
-	return EOK;
+	return rc;
 }
 
@@ -544,5 +545,5 @@
 		uint32_t *iblock, uint32_t *fblock)
 {
-	int rc;
+	int rc = EOK;
 
 	ext4_superblock_t *sb = inode_ref->fs->superblock;
@@ -569,5 +570,4 @@
 	rc = ext4_extent_find_extent(inode_ref, new_block_idx, &path);
 	if (rc != EOK) {
-		EXT4FS_DBG("find extent ERROR");
 		return rc;
 	}
@@ -590,6 +590,5 @@
 		rc = ext4_balloc_alloc_block(inode_ref, &phys_block);
 		if (rc != EOK) {
-			EXT4FS_DBG("ERRO in balloc");
-			return rc;
+			goto finish;
 		}
 
@@ -626,5 +625,5 @@
 	free(path);
 
-	return EOK;
+	return rc;
 }
 
