projects
/
systemd
/
.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
247738b
)
loop-util: close lock fd before trying LOOP_CLR_FD in failure path
author
Lennart Poettering
<lennart@poettering.net>
Thu, 1 Sep 2022 13:42:32 +0000
(15:42 +0200)
committer
Lennart Poettering
<lennart@poettering.net>
Thu, 1 Sep 2022 20:06:19 +0000
(22:06 +0200)
If the loopback device is open more than once LOOP_CLR_FD will fail,
hence close the lock fd first explicitly, so there's definitely only one
fd left.
src/shared/loop-util.c
patch
|
blob
|
history
diff --git
a/src/shared/loop-util.c
b/src/shared/loop-util.c
index 81682994de6cd061795d3c2cc543b94096250789..6cb370e95079484191d80c665082ae30904c4f1f 100644
(file)
--- a/
src/shared/loop-util.c
+++ b/
src/shared/loop-util.c
@@
-341,6
+341,9
@@
success:
return 0;
fail:
+ /* Close the lock fd explicitly before clearing the loopback block device, since an additional open
+ * fd would block the clearing to succeed */
+ lock_fd = safe_close(lock_fd);
(void) ioctl(fd, LOOP_CLR_FD);
return r;
}