Index: uspace/lib/c/generic/dirent.c
===================================================================
--- uspace/lib/c/generic/dirent.c	(revision 128a311e02aa7ad74377185bd929a82874cfcade)
+++ uspace/lib/c/generic/dirent.c	(revision b0178856327e4f27aa16082db4022897e58d8f86)
@@ -84,6 +84,6 @@
 
 	DIR *dirp = opendir_internal(my_handle);
-	rc = errno;
-	if (rc != EOK) {
+	if (!dirp) {
+		rc = errno;
 		vfs_put(my_handle);
 		errno = rc;
@@ -109,6 +109,6 @@
 
 	DIR *dirp = opendir_internal(fd);
-	rc = errno;
-	if (rc != EOK) {
+	if (!dirp) {
+		rc = errno;
 		vfs_put(fd);
 		errno = rc;
