When devfs dirent is freed, a vnode might still keep a pointer to it,

apparently.  Interlock and clear the pointer to avoid free memory
dereference.

Submitted by:	bde (previous version)
MFC after:	3 weeks
This commit is contained in:
Konstantin Belousov 2016-01-22 20:30:51 +00:00
parent be62a642f2
commit 1a2dd035fb

View File

@ -304,6 +304,13 @@ devfs_vmkdir(struct devfs_mount *dmp, char *name, int namelen, struct devfs_dire
void
devfs_dirent_free(struct devfs_dirent *de)
{
struct vnode *vp;
vp = de->de_vnode;
mtx_lock(&devfs_de_interlock);
if (vp != NULL && vp->v_data == de)
vp->v_data = NULL;
mtx_unlock(&devfs_de_interlock);
free(de, M_DEVFS3);
}