Index: uspace/srv/fs/ext4fs/ext4fs_ops.c
===================================================================
--- uspace/srv/fs/ext4fs/ext4fs_ops.c	(revision 6749febbf14fcee65590d678af2d7f90b8921903)
+++ uspace/srv/fs/ext4fs/ext4fs_ops.c	(revision e5a1ace31a3fced247ff6f421a3de1c6328973e8)
@@ -259,8 +259,12 @@
 	rc = ext4fs_node_get_core(rfn, eparent->instance, inode);
 	if (rc != EOK)
-		return rc;
-	
+		goto exit;
+
+exit:
+	;
+
 	/* Destroy search result structure */
-	return ext4_directory_destroy_result(&result);
+	int const rc2 = ext4_directory_destroy_result(&result);
+	return rc == EOK ? rc2 : rc;
 }
 
@@ -1002,7 +1006,5 @@
 	*lnkcnt = 1;
 	
-	ext4fs_node_put(root_node);
-	
-	return EOK;
+	return ext4fs_node_put(root_node);
 }
 
@@ -1093,7 +1095,7 @@
 	}
 	
-	ext4_filesystem_put_inode_ref(inode_ref);
-	
-	return rc;
+	int const rc2 = ext4_filesystem_put_inode_ref(inode_ref);
+	
+	return rc == EOK ? rc2 : rc;
 }
 
@@ -1268,9 +1270,9 @@
 		memset(buffer, 0, bytes);
 		
-		async_data_read_finalize(callid, buffer, bytes);
+		rc = async_data_read_finalize(callid, buffer, bytes);
 		*rbytes = bytes;
 		
 		free(buffer);
-		return EOK;
+		return rc;
 	}
 	
@@ -1284,5 +1286,9 @@
 	
 	assert(offset_in_block + bytes <= block_size);
-	async_data_read_finalize(callid, block->data + offset_in_block, bytes);
+	rc = async_data_read_finalize(callid, block->data + offset_in_block, bytes);
+	if (rc != EOK) {
+		block_put(block);
+		return rc;
+	}
 	
 	rc = block_put(block);
@@ -1316,7 +1322,7 @@
 	size_t len;
 	if (!async_data_write_receive(&callid, &len)) {
-		ext4fs_node_put(fn);
-		async_answer_0(callid, EINVAL);
-		return EINVAL;
+		rc = EINVAL;
+		async_answer_0(callid, rc);
+		goto exit;
 	}
 	
@@ -1341,7 +1347,6 @@
 	    &fblock);
 	if (rc != EOK) {
-		ext4fs_node_put(fn);
 		async_answer_0(callid, rc);
-		return rc;
+		goto exit;
 	}
 	
@@ -1359,7 +1364,6 @@
 				    &fblock, true);
 				if (rc != EOK) {
-					ext4fs_node_put(fn);
 					async_answer_0(callid, rc);
-					return rc;
+					goto exit;
 				}
 			}
@@ -1368,14 +1372,12 @@
 			    &fblock, false);
 			if (rc != EOK) {
-				ext4fs_node_put(fn);
 				async_answer_0(callid, rc);
-				return rc;
+				goto exit;
 			}
 		} else {
 			rc = ext4_balloc_alloc_block(inode_ref, &fblock);
 			if (rc != EOK) {
-				ext4fs_node_put(fn);
 				async_answer_0(callid, rc);
-				return rc;
+				goto exit;
 			}
 			
@@ -1384,7 +1386,6 @@
 			if (rc != EOK) {
 				ext4_balloc_free_block(inode_ref, fblock);
-				ext4fs_node_put(fn);
 				async_answer_0(callid, rc);
-				return rc;
+				goto exit;
 			}
 		}
@@ -1398,27 +1399,22 @@
 	rc = block_get(&write_block, service_id, fblock, flags);
 	if (rc != EOK) {
-		ext4fs_node_put(fn);
 		async_answer_0(callid, rc);
-		return rc;
+		goto exit;
 	}
 	
 	if (flags == BLOCK_FLAGS_NOREAD)
 		memset(write_block->data, 0, block_size);
-	
+
 	rc = async_data_write_finalize(callid, write_block->data +
 	    (pos % block_size), bytes);
-	if (rc != EOK) {
-		ext4fs_node_put(fn);
-		return rc;
-	}
-	
+	if (rc != EOK)
+		goto exit;
+
 	write_block->dirty = true;
 	
 	rc = block_put(write_block);
-	if (rc != EOK) {
-		ext4fs_node_put(fn);
-		return rc;
-	}
-	
+	if (rc != EOK)
+		goto exit;
+
 	/* Do some counting */
 	uint32_t old_inode_size = ext4_inode_get_size(fs->superblock,
@@ -1428,9 +1424,13 @@
 		inode_ref->dirty = true;
 	}
-	
+
 	*nsize = ext4_inode_get_size(fs->superblock, inode_ref->inode);
 	*wbytes = bytes;
-	
-	return ext4fs_node_put(fn);
+
+exit:
+	;
+
+	int const rc2 = ext4fs_node_put(fn);
+	return rc == EOK ? rc2 : rc;
 }
 
@@ -1458,7 +1458,7 @@
 	
 	rc = ext4_filesystem_truncate_inode(inode_ref, new_size);
-	ext4fs_node_put(fn);
-	
-	return rc;
+	int const rc2 = ext4fs_node_put(fn);
+	
+	return rc == EOK ? rc2 : rc;
 }
 
