kernel - Fix memory leak when execv()ing certain paths.
[dragonfly.git] / 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