Merge "Use errno correctly."
diff --git a/Loop.cpp b/Loop.cpp
index b1e9f6a..37ad102 100644
--- a/Loop.cpp
+++ b/Loop.cpp
@@ -103,10 +103,11 @@
         }
 
         rc = ioctl(fd, LOOP_GET_STATUS64, &li);
-        close(fd);
         if (rc < 0 && errno == ENXIO) {
+            close(fd);
             continue;
         }
+        close(fd);
 
         if (rc < 0) {
             SLOGE("Unable to get loop status for %s (%s)", filename,