[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <32127.1460484373@warthog.procyon.org.uk>
Date: Tue, 12 Apr 2016 19:06:13 +0100
From: David Howells <dhowells@...hat.com>
To: Sudip Mukherjee <sudipm.mukherjee@...il.com>
Cc: dhowells@...hat.com, linux-kernel@...r.kernel.org,
mkayaalp@...ux.vnet.ibm.com
Subject: Re: [PATCH] KEYS: fix memory leak
Sudip Mukherjee <sudipm.mukherjee@...il.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);
Powered by blists - more mailing lists