lkml.org 
[lkml]   [2016]   [Apr]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] KEYS: fix memory leak
Date
Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote:

> If the file read fails then we returned NULL as error but we missed
> freeing buf.

It's not a particularly critical error since it's a build-time script rather
than the kernel. Possibly read_file() and map_file() should just exit upon
encountering an error rather than returning.

David

> diff --git a/scripts/insert-sys-cert.c b/scripts/insert-sys-cert.c
> index 8902836..b98a0b1 100644
> --- a/scripts/insert-sys-cert.c
> +++ b/scripts/insert-sys-cert.c
> @@ -251,6 +251,7 @@ static char *read_file(char *file_name, int *size)
> if (read(fd, buf, *size) != *size) {
> perror("File read failed");
> close(fd);
> + free(buf);
> return NULL;
> }
> close(fd);

\
 
 \ /
  Last update: 2016-04-12 20:21    [W:0.038 / U:0.236 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site