Index: uspace/srv/fs/fat/fat_ops.c
===================================================================
--- uspace/srv/fs/fat/fat_ops.c	(revision e6bc3a582186c3c564e203cf60108352cb4f2184)
+++ uspace/srv/fs/fat/fat_ops.c	(revision 17bf6589140203b151bde03d340d98bd7a813224)
@@ -115,5 +115,5 @@
 }
 
-static fat_node_t *fat_node_get_new(void)
+static int fat_node_get_new(fat_node_t **nodepp)
 {
 	fs_node_t *fn;
@@ -137,5 +137,12 @@
 		if (nodep->dirty) {
 			rc = fat_node_sync(nodep);
-			assert(rc == EOK);
+			if (rc != EOK) {
+				idxp_tmp->nodep = NULL;
+				fibril_mutex_unlock(&nodep->lock);
+				fibril_mutex_unlock(&idxp_tmp->lock);
+				free(nodep->bp);
+				free(nodep);
+				return rc;
+			}
 		}
 		idxp_tmp->nodep = NULL;
@@ -149,9 +156,9 @@
 		fn = (fs_node_t *)malloc(sizeof(fs_node_t));
 		if (!fn)
-			return NULL;
+			return ENOMEM;
 		nodep = (fat_node_t *)malloc(sizeof(fat_node_t));
 		if (!nodep) {
 			free(fn);
-			return NULL;
+			return ENOMEM;
 		}
 	}
@@ -161,5 +168,6 @@
 	nodep->bp = fn;
 	
-	return nodep;
+	*nodepp = nodep;
+	return EOK;
 }
 
@@ -200,6 +208,6 @@
 	assert(idxp->pfc);
 
-	nodep = fat_node_get_new();
-	if (!nodep)
+	rc = fat_node_get_new(&nodep);
+	if (rc != EOK)
 		return NULL;
 
@@ -432,8 +440,8 @@
 	}
 
-	nodep = fat_node_get_new();
-	if (!nodep) {
+	rc = fat_node_get_new(&nodep);
+	if (rc != EOK) {
 		(void) fat_free_clusters(bs, dev_handle, mcl);
-		return ENOMEM;	/* FIXME: determine the true error code */
+		return rc;
 	}
 	idxp = fat_idx_get_new(dev_handle);
