mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: dhowells@redhat.com, linux-kernel@vger.kernel.org,
	mkayaalp@linux.vnet.ibm.com
Subject: Re: [PATCH] KEYS: fix memory leak
Date: Tue, 12 Apr 2016 19:06:13 +0100	[thread overview]
Message-ID: <32127.1460484373@warthog.procyon.org.uk> (raw)
In-Reply-To: <1460463119-8409-1-git-send-email-sudipm.mukherjee@gmail.com>

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);

      reply	other threads:[~2016-04-12 18:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-12 12:11 Sudip Mukherjee
2016-04-12 18:06 ` David Howells [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=32127.1460484373@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkayaalp@linux.vnet.ibm.com \
    --cc=sudipm.mukherjee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome