kernel - Fix memory leak when execv()ing certain paths.
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 27 Oct 2011 02:03:42 +0000 (19:03 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 27 Oct 2011 02:03:42 +0000 (19:03 -0700)
* Fix a memory leak when execv()ing paths prefixed with a "./"

sys/kern/kern_exec.c

index e5b0a77..f8ae5af 100644 (file)
@@ -554,15 +554,15 @@ exec_fail_dealloc:
                imgp->vp = NULL;
        }
 
+       if (imgp->freepath)
+               kfree(imgp->freepath, M_TEMP);
+
        if (error == 0) {
                ++mycpu->gd_cnt.v_exec;
                lwkt_reltoken(&p->p_token);
                return (0);
        }
 
-       if (imgp->freepath)
-               kfree(imgp->freepath, M_TEMP);
-
 exec_fail:
        /*
         * we're done here, clear P_INEXEC if we were the ones that