Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Jul 2006 11:52:12 GMT
From:      Roman Divacky <rdivacky@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 102643 for review
Message-ID:  <200607281152.k6SBqC8M021388@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=102643

Change 102643 by rdivacky@rdivacky_witten on 2006/07/28 11:51:42

	Dont leak linux_emuldata_shared on every execve() call. Also remove trailing ;
	in if().

Affected files ...

.. //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux_machdep.c#25 edit

Differences ...

==== //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux_machdep.c#25 (text+ko) ====

@@ -1156,29 +1156,31 @@
 
 	em->child_clear_tid = NULL;
 	em->child_set_tid = NULL;
-	em->shared = NULL;
 
-	if (flags & CLONE_VM) {
-	   	printf("CLONE_VM!!!!!\n");
-	   	/* lookup the parent */
-	   	p_em = em_find(td->td_proc->p_pptr->p_pid, EMUL_LOCKED);
-		if (p_em == NULL) {
+	/* allocate the shared struct only in non-exec cases */
+	if (child != 0) {
+   	   	em->shared = NULL;
+   	   	if (flags & CLONE_VM) {
+   		   	/* lookup the parent */
+   		   	p_em = em_find(td->td_proc->p_pptr->p_pid, EMUL_LOCKED);
+			if (p_em == NULL) {
 #ifdef DEBUG	
-		   	printf(LMSG("parent emuldata not found for CLONE_VM.\n"));
+		   		printf(LMSG("parent emuldata not found for CLONE_VM.\n"));
 #endif
-		} else {
-	   		em->shared = p_em->shared;
-			em->shared->refs++;
+			} else {
+	   			em->shared = p_em->shared;
+				em->shared->refs++;
 #ifdef DEBUG
 #endif
+			}
+		} else {
+	   		struct linux_emuldata_shared *s;
+
+   			MALLOC(s, struct linux_emuldata_shared *, sizeof *s, M_LINUX, M_WAITOK | M_ZERO);
+			em->shared = s;
+			s->refs = 1;
+			s->group_pid = td->td_proc->p_pid;
 		}
-	} else {
-	   	struct linux_emuldata_shared *s;
-
-   		MALLOC(s, struct linux_emuldata_shared *, sizeof *s, M_LINUX, M_WAITOK | M_ZERO);
-		em->shared = s;
-		s->refs = 1;
-		s->group_pid = td->td_proc->p_pid;
 	}
 
 	if (child != 0)
@@ -1234,7 +1236,7 @@
 	}
 
 	em->shared->refs--;
-	if (em->shared->refs == 0);
+	if (em->shared->refs == 0)
 		FREE(em->shared, M_LINUX);
 
 	EMUL_RUNLOCK(&emul_lock);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607281152.k6SBqC8M021388>