lkml.org 
[lkml]   [2015]   [Apr]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] s390: char: con3215: Free memory in error path
On Sun, 19 Apr 2015 15:17:36 +0200
Christophe Jaillet <christophe.jaillet@wanadoo.fr> wrote:

> If one memory allocation fails, there is a memory leak.
>
> Signed-off-by: Christophe Jaillet <christophe.jaillet@wanadoo.fr>
> ---
> drivers/s390/char/con3215.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
> index c43aca6..0fc3fe5 100644
> --- a/drivers/s390/char/con3215.c
> +++ b/drivers/s390/char/con3215.c
> @@ -667,6 +667,8 @@ static struct raw3215_info *raw3215_alloc_info(void)
> info->buffer = kzalloc(RAW3215_BUFFER_SIZE, GFP_KERNEL | GFP_DMA);
> info->inbuf = kzalloc(RAW3215_INBUF_SIZE, GFP_KERNEL | GFP_DMA);
> if (!info->buffer || !info->inbuf) {
> + kfree(info->inbuf);
> + kfree(info->buffer);
> kfree(info);
> return NULL;
> }

Applied, thanks.

--
blue skies,
Martin.

"Reality continues to ruin my life." - Calvin.



\
 
 \ /
  Last update: 2015-04-20 11:01    [W:0.062 / U:7.416 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site