svn commit: r237276 - head/sys/kern

Pawel Jakub Dawidek pjd at FreeBSD.org
Tue Jun 19 22:22:00 UTC 2012


Author: pjd
Date: Tue Jun 19 22:21:59 2012
New Revision: 237276
URL: http://svn.freebsd.org/changeset/base/237276

Log:
  The falloc() function obtains two references to newly created 'fp'.
  On success we have to drop one after procdesc_finit() and on failure
  we have to close allocated slot with fdclose(), which also drops one
  reference for us and drop the remaining reference with fdrop().
  
  Without this change closing process descriptor didn't result in killing
  pdfork(2)ed child.
  
  Reviewed by:	rwatson
  MFC after:	1 month

Modified:
  head/sys/kern/kern_fork.c

Modified: head/sys/kern/kern_fork.c
==============================================================================
--- head/sys/kern/kern_fork.c	Tue Jun 19 19:40:54 2012	(r237275)
+++ head/sys/kern/kern_fork.c	Tue Jun 19 22:21:59 2012	(r237276)
@@ -921,8 +921,10 @@ fork1(struct thread *td, int flags, int 
 		 */
 		*procp = newproc;
 #ifdef PROCDESC
-		if (flags & RFPROCDESC)
+		if (flags & RFPROCDESC) {
 			procdesc_finit(newproc->p_procdesc, fp_procdesc);
+			fdrop(fp_procdesc, td);
+		}
 #endif
 		racct_proc_fork_done(newproc);
 		return (0);
@@ -944,8 +946,10 @@ fail1:
 		vmspace_free(vm2);
 	uma_zfree(proc_zone, newproc);
 #ifdef PROCDESC
-	if (((flags & RFPROCDESC) != 0) && (fp_procdesc != NULL))
+	if (((flags & RFPROCDESC) != 0) && (fp_procdesc != NULL)) {
+		fdclose(td->td_proc->p_fd, fp_procdesc, *procdescp, td);
 		fdrop(fp_procdesc, td);
+	}
 #endif
 	pause("fork", hz / 2);
 	return (error);


More information about the svn-src-all mailing list