[PATCH 6/7] erofs-utils: mount: fix `RESOURCE_LEAK`
Gao Xiang <[email protected]> Tue, 30 Jun 2026 10:52:23 +0800
| Newsgroups | org.ozlabs.lists.linux-erofs |
|---|---|
| Message-ID | <[email protected]> |
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