mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
To: Jarkko Sakkinen <jarkko@kernel.org>,
	David Howells <dhowells@redhat.com>,
	David Woodhouse <dwmw2@infradead.org>,
	keyrings@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Subject: [PATCH] sign-file: fix memory leak
Date: Thu, 25 May 2023 16:43:24 +0800	[thread overview]
Message-ID: <20230525084324.56718-1-tianjia.zhang@linux.alibaba.com> (raw)

The buffer allocated by asprintf() must be freeed.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
---
 scripts/sign-file.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/sign-file.c b/scripts/sign-file.c
index b90fc9f7437f..94267cf72197 100644
--- a/scripts/sign-file.c
+++ b/scripts/sign-file.c
@@ -369,6 +369,7 @@ int main(int argc, char **argv)
 			    "%s", sig_file_name);
 #endif
 			BIO_free(b);
+			free(sig_file_name);
 		}
 
 		if (sign_only) {
@@ -420,8 +421,10 @@ int main(int argc, char **argv)
 	ERR(BIO_free(bd) < 0, "%s", dest_name);
 
 	/* Finally, if we're signing in place, replace the original. */
-	if (replace_orig)
+	if (replace_orig) {
 		ERR(rename(dest_name, module_name) < 0, "%s", dest_name);
+		free(dest_name);
+	}
 
 	return 0;
 }
-- 
2.24.3 (Apple Git-128)


             reply	other threads:[~2023-05-25  8:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-25  8:43 Tianjia Zhang [this message]
2023-06-09 17:45 ` Jarkko Sakkinen

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=20230525084324.56718-1-tianjia.zhang@linux.alibaba.com \
    --to=tianjia.zhang@linux.alibaba.com \
    --cc=dhowells@redhat.com \
    --cc=dwmw2@infradead.org \
    --cc=jarkko@kernel.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®