Author: kib
Date: Mon Jan 19 17:24:52 2015
New Revision: 277390
URL: https://svnweb.freebsd.org/changeset/base/277390

Log:
  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

Modified:
  head/sys/fs/devfs/devfs_devs.c
  head/sys/fs/devfs/devfs_vnops.c

Modified: head/sys/fs/devfs/devfs_devs.c
==============================================================================
--- head/sys/fs/devfs/devfs_devs.c      Mon Jan 19 17:02:30 2015        
(r277389)
+++ head/sys/fs/devfs/devfs_devs.c      Mon Jan 19 17:24:52 2015        
(r277390)
@@ -192,6 +192,16 @@ devfs_find(struct devfs_dirent *dd, cons
                        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;

Modified: head/sys/fs/devfs/devfs_vnops.c
==============================================================================
--- head/sys/fs/devfs/devfs_vnops.c     Mon Jan 19 17:02:30 2015        
(r277389)
+++ head/sys/fs/devfs/devfs_vnops.c     Mon Jan 19 17:24:52 2015        
(r277390)
@@ -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;
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to