Re: small memory leak in exec.c if exec_mmap fails

Phil Brutsche (pbrutsch@creighton.edu)
Sun, 4 Jan 1998 02:21:34 -0600 (CST)


You didn't say - what kernel version is this for? 2.0.x or 2.1.x?

On Fri, 2 Jan 1998, Peeter Joot wrote:

> Hello,
>
> I think I have noticed a small memory leak in exec.c:flush_old_exec().
>
> If exec_mmap() fails on a process that has CLONE_SIGHAND created clones
> then the kmalloc'ed signal_struct won't be freed.
>
> I have attached a small patch that should fix this (untested as
> it as it is not an easily reprodable scenerio)
>
> Peeter
> --
> Peeter Joot
> http://www.accessv.com/~peeter peeter@accessv.com
>
>
>
> --- exec.c.orig Fri Jan 2 00:16:39 1998
> +++ exec.c Fri Jan 2 00:16:07 1998
> @@ -518,7 +518,7 @@
> * Release all of the old mmap stuff
> */
> retval = exec_mmap();
> - if (retval) goto flush_failed;
> + if (retval) goto mmap_failed;
>
> /* This is the point of no return */
> release_old_signals(oldsig);
> @@ -547,6 +547,9 @@
>
> return 0;
>
> +mmap_failed:
> + if (current->sig != oldsig)
> + kfree(current->sig);
> flush_failed:
> current->sig = oldsig;
> return retval;
>

----------------------------------------------------------------------
Phil Brutsche

"Be of stout heart, Number One. We've handled the Borg. We can
certainly handle Admiral Jellico." - Jean-Luc Picard

----------------------------------------------------------------------