Index: uspace/srv/fs/fat/fat_ops.c
===================================================================
--- uspace/srv/fs/fat/fat_ops.c	(revision 453f2e75937cb216fd76a69396c5702b117b2b35)
+++ uspace/srv/fs/fat/fat_ops.c	(revision bccec987843c8e9c688b8a455c308951fd14bae1)
@@ -1172,5 +1172,5 @@
 	fat_node_t *nodep;
 	fat_bs_t *bs;
-	size_t bytes;
+	size_t bytes, size;
 	block_t *b;
 	uint16_t bps;
@@ -1195,5 +1195,5 @@
 	size_t len;
 	if (!async_data_write_receive(&callid, &len)) {
-		fat_node_put(fn);
+		(void) fat_node_put(fn);
 		ipc_answer_0(callid, EINVAL);
 		ipc_answer_0(rid, EINVAL);
@@ -1226,18 +1226,33 @@
 		 */
 		rc = fat_fill_gap(bs, nodep, FAT_CLST_RES0, pos);
-		assert(rc == EOK);
+		if (rc != EOK) {
+			(void) fat_node_put(fn);
+			ipc_answer_0(callid, rc);
+			ipc_answer_0(rid, rc);
+			return;
+		}
 		rc = fat_block_get(&b, bs, nodep, pos / bps, flags);
-		assert(rc == EOK);
+		if (rc != EOK) {
+			(void) fat_node_put(fn);
+			ipc_answer_0(callid, rc);
+			ipc_answer_0(rid, rc);
+			return;
+		}
 		(void) async_data_write_finalize(callid, b->data + pos % bps,
 		    bytes);
 		b->dirty = true;		/* need to sync block */
 		rc = block_put(b);
-		assert(rc == EOK);
+		if (rc != EOK) {
+			(void) fat_node_put(fn);
+			ipc_answer_0(rid, rc);
+			return;
+		}
 		if (pos + bytes > nodep->size) {
 			nodep->size = pos + bytes;
 			nodep->dirty = true;	/* need to sync node */
 		}
-		ipc_answer_2(rid, EOK, bytes, nodep->size);	
-		fat_node_put(fn);
+		size = nodep->size;
+		rc = fat_node_put(fn);
+		ipc_answer_2(rid, rc, bytes, nodep->size);
 		return;
 	} else {
@@ -1246,5 +1261,4 @@
 		 * clusters for the node and zero them out.
 		 */
-		int status;
 		unsigned nclsts;
 		fat_cluster_t mcl, lcl; 
@@ -1252,23 +1266,40 @@
 		nclsts = (ROUND_UP(pos + bytes, bpc) - boundary) / bpc;
 		/* create an independent chain of nclsts clusters in all FATs */
-		status = fat_alloc_clusters(bs, dev_handle, nclsts, &mcl, &lcl);
-		if (status != EOK) {
+		rc = fat_alloc_clusters(bs, dev_handle, nclsts, &mcl, &lcl);
+		if (rc != EOK) {
 			/* could not allocate a chain of nclsts clusters */
-			fat_node_put(fn);
-			ipc_answer_0(callid, status);
-			ipc_answer_0(rid, status);
+			(void) fat_node_put(fn);
+			ipc_answer_0(callid, rc);
+			ipc_answer_0(rid, rc);
 			return;
 		}
 		/* zero fill any gaps */
 		rc = fat_fill_gap(bs, nodep, mcl, pos);
-		assert(rc == EOK);
+		if (rc != EOK) {
+			(void) fat_free_clusters(bs, dev_handle, mcl);
+			(void) fat_node_put(fn);
+			ipc_answer_0(callid, rc);
+			ipc_answer_0(rid, rc);
+			return;
+		}
 		rc = _fat_block_get(&b, bs, dev_handle, lcl, (pos / bps) % spc,
 		    flags);
-		assert(rc == EOK);
+		if (rc != EOK) {
+			(void) fat_free_clusters(bs, dev_handle, mcl);
+			(void) fat_node_put(fn);
+			ipc_answer_0(callid, rc);
+			ipc_answer_0(rid, rc);
+			return;
+		}
 		(void) async_data_write_finalize(callid, b->data + pos % bps,
 		    bytes);
 		b->dirty = true;		/* need to sync block */
 		rc = block_put(b);
-		assert(rc == EOK);
+		if (rc != EOK) {
+			(void) fat_free_clusters(bs, dev_handle, mcl);
+			(void) fat_node_put(fn);
+			ipc_answer_0(rid, rc);
+			return;
+		}
 		/*
 		 * Append the cluster chain starting in mcl to the end of the
@@ -1276,9 +1307,14 @@
 		 */
 		rc = fat_append_clusters(bs, nodep, mcl);
-		assert(rc == EOK);
-		nodep->size = pos + bytes;
+		if (rc != EOK) {
+			(void) fat_free_clusters(bs, dev_handle, mcl);
+			(void) fat_node_put(fn);
+			ipc_answer_0(rid, rc);
+			return;
+		}
+		nodep->size = size = pos + bytes;
 		nodep->dirty = true;		/* need to sync node */
-		ipc_answer_2(rid, EOK, bytes, nodep->size);
-		fat_node_put(fn);
+		rc = fat_node_put(fn);
+		ipc_answer_2(rid, rc, bytes, size);
 		return;
 	}
