Subject: Re: Bug in kernfs_mount()?
To: None <>
From: Christos Zoulas <>
List: tech-kern
Date: 05/26/2004 17:35:11
In article <c92c1j$mmj$>,
Matthias Scheler <> wrote:
>	Hello,
>kernfs_mount() looks like this:
>kernfs_mount(mp, path, data, ndp, p)
>	struct mount *mp;
>	const char *path;
>	void *data;
>	struct nameidata *ndp;
>	struct proc *p;
>	int error = 0;
>	struct kernfs_mount *fmp;
>	MALLOC(fmp, struct kernfs_mount *, sizeof(struct kernfs_mount),
>	mp->mnt_data = fmp;
>	mp->mnt_flag |= MNT_LOCAL;
>	vfs_getnewfsid(mp);
>	error = set_statvfs_info(path, UIO_USERSPACE, "kernfs", UIO_SYSSPACE,
>	    mp, p);
>	kernfs_get_rrootdev();
>	return error;
>If set_statvfs_info() returns an error the call to VFS_MOUNT() will fail
>and "fmp" will be leaked. Is that correct or will VFS_UNMOUNT() called
>even if a mount attempt fails?

Yes this is a leak; on some filesystems like the above, it can be easily
fixed by free-ing the memory. On others it is more complicated. The
choice is to ignore the error and return 0 having wrong info, or leak.
In this case the error is generated by copying in the path, which should
not happen. Send-pr it.