Coverity-id: 647246
Signed-off-by: Gao Xiang <[email protected]>
---
 mount/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/mount/main.c b/mount/main.c
index ffe718a0a90f..ec27dcb53eb3 100644
--- a/mount/main.c
+++ b/mount/main.c
@@ -1698,8 +1698,11 @@ static int erofsmount_loopmount(const char *source, 
const char *mountpoint,
                return -errno;
 
        num = ioctl(fd, LOOP_CTL_GET_FREE);
-       if (num < 0)
-               return -errno;
+       if (num < 0) {
+               dfd = -errno;
+               close(fd);
+               return dfd;
+       }
        close(fd);
 
        snprintf(device, sizeof(device), "/dev/loop%d", num);
-- 
2.43.5


Reply via email to