Fix a memory leak when kern_execve() fails fatally.
authorSimon Schubert <corecode@dragonflybsd.org>
Mon, 30 Jul 2007 14:52:40 +0000 (14:52 +0000)
committerSimon Schubert <corecode@dragonflybsd.org>
Mon, 30 Jul 2007 14:52:40 +0000 (14:52 +0000)
commit5417cd5783312661998882b14e37b81278c64734
tree6584ec8aa335559889cf334e1dd685f11ddb2e88
parente0ab0dda4467a333f1c9f1d382f74e3d830a5ed9
Fix a memory leak when kern_execve() fails fatally.

The callers of execve() are taking care of releasing the argument
buffer for exec.  However, there might be situations where exec
ran into a dead end and can't come out again because it already
has destroyed the calling process image.  In these cases kern_execve
was calling exit1() to destroy the current process.  This however means
that the argument buffers were never freed, thus causing the leak.

In combination with the recent change to using the objcache with a
hard upper allocation limit, this meant that at some point no binaries
could be execed anymore, stalling callers of sys_exec() in objcache_get.

To fix this business, kern_execve() now does not call exit1() on
leathal errors anymore, but instead returns -1 (in contrast to valid
errno values which are >= 0) to indicate that the current process has
to commit suicide after cleaning up used resources.
sys/emulation/linux/i386/linux_machdep.c
sys/kern/kern_exec.c