[issue1777] vn panic: Freeing already free credential! 0xdef403f8

Joe Talbott josepht at cstone.net
Sat Jun 5 15:19:04 PDT 2010


On Sat, Jun 05, 2010 at 06:13:29PM -0400, Joe Talbott wrote:
> 
> Please try this patch.  I was able to vnconfig a file following the
> vkernel manpage without a panic.  This isn't likely a long term
> solution but will hopefully allow you to proceed with your GSoC work
> in a vkernel.  If you see this panic again let me know and I'll work
> on implementing the crhold() et al. calls as Matt suggested.
> 

Forgot to copy the patch to my mail server.  This is the one I
intended to send.

Thanks,
Joe
diff --git a/sys/dev/disk/vn/vn.c b/sys/dev/disk/vn/vn.c
index 95bcf44..f7f216f 100644
--- a/sys/dev/disk/vn/vn.c
+++ b/sys/dev/disk/vn/vn.c
@@ -690,17 +690,19 @@ vniocattach_swap(struct vn_softc *vn, struct vn_ioctl *vio, cdev_t dev,
 int
 vnsetcred(struct vn_softc *vn, struct ucred *cred)
 {
+	struct ucred *ocred;
 	char *tmpbuf;
 	int error = 0;
 
 	/*
 	 * Set credits in our softc
 	 */
-
-	if (vn->sc_cred)
-		crfree(vn->sc_cred);
+	ocred = vn->sc_cred;
 	vn->sc_cred = crdup(cred);
 
+	if (ocred)
+		crfree(ocred);
+
 	/*
 	 * Horrible kludge to establish credentials for NFS  XXX.
 	 */




More information about the Bugs mailing list