Index: uspace/lib/c/generic/dirent.c
===================================================================
--- uspace/lib/c/generic/dirent.c	(revision 8c35ebd2436462e92ef76474c72b0a2a5d964559)
+++ uspace/lib/c/generic/dirent.c	(revision 7952b336d724f083cb8d6f8405136a1518af19f3)
@@ -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;
