Ignore devfs directory entries for devices either being destroyed or

delisted.  The check is racy.

Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2015-01-19 17:24:52 +00:00
parent 438e86ce0c
commit a57a934a38
2 changed files with 13 additions and 0 deletions

View File

@ -192,6 +192,16 @@ devfs_find(struct devfs_dirent *dd, const char *name, int namelen, int type)
continue;
if (type != 0 && type != de->de_dirent->d_type)
continue;
/*
* The race with finding non-active name is not
* completely closed by the check, but it is similar
* to the devfs_allocv() in making it unlikely enough.
*/
if (de->de_dirent->d_type == DT_CHR &&
(de->de_cdp->cdp_flags & CDP_ACTIVE) == 0)
continue;
if (bcmp(name, de->de_dirent->d_name, namelen) != 0)
continue;
break;

View File

@ -1045,6 +1045,9 @@ devfs_mknod(struct vop_mknod_args *ap)
TAILQ_FOREACH(de, &dd->de_dlist, de_list) {
if (cnp->cn_namelen != de->de_dirent->d_namlen)
continue;
if (de->de_dirent->d_type == DT_CHR &&
(de->de_cdp->cdp_flags & CDP_ACTIVE) == 0)
continue;
if (bcmp(cnp->cn_nameptr, de->de_dirent->d_name,
de->de_dirent->d_namlen) != 0)
continue;