svn commit: r293825 - head/sys/dev/pty

Konstantin Belousov kib at FreeBSD.org
Wed Jan 13 12:01:30 UTC 2016


Author: kib
Date: Wed Jan 13 12:01:28 2016
New Revision: 293825
URL: https://svnweb.freebsd.org/changeset/base/293825

Log:
  Switch legacy pty clone handler to use make_dev_s(9).  Add
  MAKEDEV_CHECKNAME flag to the call, this is required to not panic on
  race between the clone and destructing the closed master.
  
  Reported by and discussed with:	bde
  Tested by:	pho (as part of the larger patch)
  Sponsored by:	The FreeBSD Foundation
  MFC after:	3 weeks

Modified:
  head/sys/dev/pty/pty.c

Modified: head/sys/dev/pty/pty.c
==============================================================================
--- head/sys/dev/pty/pty.c	Wed Jan 13 09:26:44 2016	(r293824)
+++ head/sys/dev/pty/pty.c	Wed Jan 13 12:01:28 2016	(r293825)
@@ -97,6 +97,8 @@ static void
 pty_clone(void *arg, struct ucred *cr, char *name, int namelen,
     struct cdev **dev)
 {
+	struct make_dev_args mda;
+	int error;
 
 	/* Cloning is already satisfied. */
 	if (*dev != NULL)
@@ -117,8 +119,17 @@ pty_clone(void *arg, struct ucred *cr, c
 		return;
 
 	/* Create the controller device node. */
-	*dev = make_dev_credf(MAKEDEV_REF, &ptydev_cdevsw, 0,
-	    NULL, UID_ROOT, GID_WHEEL, 0666, "%s", name);
+	make_dev_args_init(&mda);
+	mda.mda_flags =  MAKEDEV_CHECKNAME | MAKEDEV_REF;
+	mda.mda_devsw = &ptydev_cdevsw;
+	mda.mda_uid = UID_ROOT;
+	mda.mda_gid = GID_WHEEL;
+	mda.mda_mode = 0666;
+	error = make_dev_s(&mda, dev, "%s", name);
+	if (error != 0) {
+		printf("pty_clone: failed to create %s: %d\n", name, error);
+		*dev = NULL;
+	}
 }
 
 static int


More information about the svn-src-head mailing list