From: Sascha Sommer Date: Tue, 21 Aug 2007 13:13:43 +0000 (+0200) Subject: mount: free loop device on failure X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c62eb4d06c83f21aa14244468a44c48c173493d;p=util-linux mount: free loop device on failure Testcase: $ mount -oloop /etc/group /mnt ioctl: LOOP_CLR_FD: Device or resource busy mount: you must specify the filesystem type $ losetup /dev/loop0 /dev/loop0: [0803]:1931929 (/etc/group) Signed-off-by: Matthias Koenig --- diff --git a/mount/fsprobe_volumeid.c b/mount/fsprobe_volumeid.c index 4b58e720..6b47392b 100644 --- a/mount/fsprobe_volumeid.c +++ b/mount/fsprobe_volumeid.c @@ -34,8 +34,10 @@ static char return NULL; id = volume_id_open_fd(fd); - if (!id) + if (!id) { + close(fd); return NULL; + } /* TODO: use blkdev_get_size() */ if (ioctl(fd, BLKGETSIZE64, &size) != 0) @@ -61,6 +63,7 @@ static char } volume_id_close(id); + close(fd); return value; } diff --git a/mount/lomount.c b/mount/lomount.c index ae9eb36e..ace474cb 100644 --- a/mount/lomount.c +++ b/mount/lomount.c @@ -398,6 +398,7 @@ del_loop (const char *device) { } if (ioctl (fd, LOOP_CLR_FD, 0) < 0) { perror ("ioctl: LOOP_CLR_FD"); + close(fd); return 1; } close (fd);