Index: uspace/srv/fs/exfat/exfat_directory.c
===================================================================
--- uspace/srv/fs/exfat/exfat_directory.c	(revision b741888a29ac45d50485a166553cae075501bd26)
+++ uspace/srv/fs/exfat/exfat_directory.c	(revision 055be8aabbcce1c30c1ae00e0e8d18872a98eb78)
@@ -285,6 +285,8 @@
 	for (i = 0; i < count; i++) {
 		rc = exfat_directory_get(di, &de);
-		if (rc != EOK)
-			return rc;
+		if (rc != EOK) {
+			free(array);
+			return rc;
+		}
 		array[i] = *de;
 		rc = exfat_directory_next(di);
@@ -312,6 +314,8 @@
 	for (i = 0; i < count; i++) {
 		rc = exfat_directory_get(di, &de);
-		if (rc != EOK)
-			return rc;
+		if (rc != EOK) {
+			free(array);
+			return rc;
+		}
 		*de = array[i];
 		di->b->dirty = true;
