* The volume init wasn't checked, so a failed init would crash.

* Unlocking a removable drive was done in the wrong error label which would've
  resulted in accessing deadbeef due to the volume being freed just before its
  use or using the not initialized volume variable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36103 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2010-04-10 12:57:17 +00:00
parent 37b79c0324
commit bb1d98b687
+8 -2
View File
@@ -577,6 +577,11 @@ mount_fat_disk(const char *path, fs_volume *_vol, const int flags,
}
vol = volume_init(fd, buf, vol_flags, fs_flags, &geo);
if (vol == NULL) {
dprintf("dosfs error: failed to initialize volume\n");
err = B_ERROR;
goto error1;
}
/* check that the partition is large enough to contain the file system */
if (vol->total_sectors > geo.sectors_per_track * geo.cylinder_count
@@ -664,12 +669,13 @@ mount_fat_disk(const char *path, fs_volume *_vol, const int flags,
error3:
uninit_vcache(vol);
error2:
volume_uninit(vol);
error1:
if (!(vol->flags & B_FS_IS_READONLY) && (vol->flags & B_FS_IS_REMOVABLE)
&& (vol->fs_flags & FS_FLAGS_LOCK_DOOR)) {
lock_removable_device(fd, false);
}
volume_uninit(vol);
error1:
close(fd);
error0:
return err >= B_NO_ERROR ? EINVAL : err;