summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSascha Sommer <ssommer@suse.de>2007-08-21 15:13:43 +0200
committerKarel Zak <kzak@redhat.com>2007-08-27 10:22:06 +0200
commit5c62eb4d06c83f21aa14244468a44c48c173493d (patch)
tree2bb3f877d707da2957bf7f838c5760184c9ef4bd
parent309fd2e79370be77c192ec272657aef9a5320ffb (diff)
downloadutil-linux-old-5c62eb4d06c83f21aa14244468a44c48c173493d.tar.gz
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 <mkoenig@suse.de>
-rw-r--r--mount/fsprobe_volumeid.c5
-rw-r--r--mount/lomount.c1
2 files changed, 5 insertions, 1 deletions
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);