1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-30 06:25:37 +03:00

loop-util: close lock fd before trying LOOP_CLR_FD in failure path

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.
This commit is contained in:
Lennart Poettering 2022-09-01 15:42:32 +02:00
parent 247738b4f5
commit 87862cc2b4

View File

@ -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;
}