Re: eject /dev/cdrom --> oops. (a better patch)

David Woodhouse (dwmw2@cam.ac.uk)
Wed, 29 Oct 1997 11:28:50 +0000


This is a multipart MIME message.

--==_Exmh_635443690
Content-Type: text/plain; charset=us-ascii

dwmw2@cam.ac.uk said:
> This isn't a real fix, but at least it stops the oopses by checking
> for that case and not attempting to dereference the pointer.

This, one the other hand, is, although I'm not sure it's the _right_ fix.
This patch still puts the check into get_filesystem_info, but it also makes
sure that do_mount will remove a vfsmnt entry after failing to complete the
mount, rather than leaving a half-initialised entry.

This has the side-effect that it will remove any existing vfsmnt entry for the
device in question if a mount fails. As I understand it, there shouldn't be
one anyway, but it's a case that the existing code checked for.

Would someone who knows what they're talking about care to pass judgement?

--==_Exmh_635443690
Content-Type: text/plain ; name="super-2-vger59"; charset=us-ascii
Content-Description: super-2-vger59
Content-Disposition: attachment; filename="super-2-vger59"

--- super.c.orig Sat Oct 18 05:12:08 1997
+++ super.c Wed Oct 29 11:17:14 1997
@@ -331,7 +331,8 @@
while ( tmp && len < PAGE_SIZE - 160)
{
len += sprintf( buf + len, "%s %s %s %s",
- tmp->mnt_devname, tmp->mnt_dirname, tmp->mnt_sb->s_type->name,
+ tmp->mnt_devname, tmp->mnt_dirname,
+ tmp->mnt_sb->s_type?tmp->mnt_sb->s_type->name:"BUG!",
tmp->mnt_flags & MS_RDONLY ? "ro" : "rw" );
for (fs_infop = fs_info; fs_infop->flag; fs_infop++) {
if (tmp->mnt_flags & fs_infop->flag) {
@@ -339,7 +340,7 @@
len += strlen(fs_infop->str);
}
}
- if (!strcmp("nfs", tmp->mnt_sb->s_type->name)) {
+ if (tmp->mnt_sb->s_type && !strcmp("nfs", tmp->mnt_sb->s_type->name)) {
nfss = &tmp->mnt_sb->u.nfs_sb.s_server;
if (nfss->rsize != NFS_DEF_FILE_IO_BUFFER_SIZE) {
len += sprintf(buf+len, ",rsize=%d",
@@ -813,7 +814,7 @@
{
struct dentry * dir_d = NULL;
struct super_block * sb;
- struct vfsmount * vfsmnt;
+ struct vfsmount * vfsmnt = NULL;
int error;

down(&mount_sem);
@@ -873,6 +874,8 @@

dput_and_out:
dput(dir_d);
+ if (vfsmnt)
+ remove_vfsmnt(dev);
out:
up(&mount_sem);
return error;

--==_Exmh_635443690--