Index: uspace/srv/fs/tmpfs/tmpfs_ops.c
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs_ops.c	(revision b8b23c8f92c4ae7bcd3dda6e4d31d25e5c0dd2d3)
+++ uspace/srv/fs/tmpfs/tmpfs_ops.c	(revision 1fe186f2fd88fc8bcd4291c8fe20c9c2a3fa2adb)
@@ -246,5 +246,5 @@
 	char component[NAME_MAX + 1];
 	int len = 0;
-	while (next <= last) {
+	while (dtmp && next <= last) {
 
 		/* collect the component */
@@ -296,47 +296,45 @@
 		dcur = dtmp;
 		dtmp = dtmp->child;
-
-		/* handle miss: excessive components */
-		if (!dtmp && next <= last) {
-			if (lflag & L_CREATE) {
-				if (dcur->type != TMPFS_DIRECTORY) {
-					ipc_answer_0(rid, ENOTDIR);
+	}
+
+	/* handle miss: excessive components */
+	if (!dtmp && next <= last) {
+		if (lflag & L_CREATE) {
+			if (dcur->type != TMPFS_DIRECTORY) {
+				ipc_answer_0(rid, ENOTDIR);
+				return;
+			}
+
+			/* collect next component */
+			while (next <= last) {
+				if (PLB_GET_CHAR(next) == '/') {
+					/* more than one component */
+					ipc_answer_0(rid, ENOENT);
 					return;
 				}
-
-				/* collect next component */
-				while (next <= last) {
-					if (PLB_GET_CHAR(next) == '/') {
-						/* more than one component */
-						ipc_answer_0(rid, ENOENT);
-						return;
-					}
-					if (len + 1 == NAME_MAX) {
-						/* component length overflow */
-						ipc_answer_0(rid, ENAMETOOLONG);
-						return;
-					}
-					component[len++] = PLB_GET_CHAR(next);
-					next++;	/* process next character */
+				if (len + 1 == NAME_MAX) {
+					/* component length overflow */
+					ipc_answer_0(rid, ENAMETOOLONG);
+					return;
 				}
-				assert(len);
-				component[len] = '\0';
-				len = 0;
+				component[len++] = PLB_GET_CHAR(next);
+				next++;	/* process next character */
+			}
+			assert(len);
+			component[len] = '\0';
+			len = 0;
 				
-				unsigned long index;
-				index = create_node(dcur, component, lflag);
-				if (index) {
-					ipc_answer_4(rid, EOK,
-					    tmpfs_reg.fs_handle, dev_handle,
-					    index, 0);
-				} else {
-					ipc_answer_0(rid, ENOSPC);
-				}
-				return;
+			unsigned long index;
+			index = create_node(dcur, component, lflag);
+			if (index) {
+				ipc_answer_4(rid, EOK, tmpfs_reg.fs_handle,
+				    dev_handle, index, 0);
+			} else {
+				ipc_answer_0(rid, ENOSPC);
 			}
-			ipc_answer_0(rid, ENOENT);
 			return;
 		}
-	
+		ipc_answer_0(rid, ENOENT);
+		return;
 	}
 
