summaryrefslogtreecommitdiff
path: root/libbb/loop.c
diff options
context:
space:
mode:
authorDenys Vlasenko2020-12-17 23:38:06 +0100
committerDenys Vlasenko2020-12-17 23:38:06 +0100
commit15733cb48e570716cad6ece2d752507ecd767131 (patch)
tree76b2de515344b892b841192e5961b660ff0da656 /libbb/loop.c
parent251e08ffa626d4b7c7e5f626aee7067b86b2ceba (diff)
downloadbusybox-15733cb48e570716cad6ece2d752507ecd767131.zip
busybox-15733cb48e570716cad6ece2d752507ecd767131.tar.gz
mount: if we race with other loop mount, we forget to close loop dev
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/loop.c')
-rw-r--r--libbb/loop.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libbb/loop.c b/libbb/loop.c
index 1539909..cb8fa24 100644
--- a/libbb/loop.c
+++ b/libbb/loop.c
@@ -187,7 +187,7 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse
//TODO: add "if (--failcount != 0) ..."?
goto get_free_loopN;
}
- goto try_next_loopN;
+ goto close_and_try_next_loopN;
}
memset(&loopinfo, 0, sizeof(loopinfo));
safe_strncpy((char *)loopinfo.lo_file_name, file, LO_NAME_SIZE);
@@ -220,6 +220,7 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse
ioctl(lfd, LOOP_CLR_FD, 0); // actually, 0 param is unnecessary
}
/* else: device is not free (rc == 0) or error other than ENXIO */
+ close_and_try_next_loopN:
close(lfd);
try_next_loopN:
rc = -1;