From: linfeilong <linfeilong@huawei.com>
To: "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH] scripts: fix memleak error in read_file
Date: Tue, 22 Oct 2019 11:47:59 +0000 [thread overview]
Message-ID: <bf5c73b4b8534189be0f0df81fe863f0@huawei.com> (raw)
An error is found by the static code analysis tool: "memleak"
Fix this by add free before return.
Signed-off-by: Feilong Lin <linfeilong@huawei.com>
---
scripts/insert-sys-cert.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/scripts/insert-sys-cert.c b/scripts/insert-sys-cert.c
index 8902836..22d99a8 100644
--- a/scripts/insert-sys-cert.c
+++ b/scripts/insert-sys-cert.c
@@ -250,6 +250,7 @@ static char *read_file(char *file_name, int *size)
}
if (read(fd, buf, *size) != *size) {
perror("File read failed");
+ free(buf);
close(fd);
return NULL;
}
--
1.8.3.1
next reply other threads:[~2019-10-22 11:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-22 11:47 linfeilong [this message]
2019-10-22 22:13 ` [PATCH] scripts: fix memleak error in read_file Andrew Morton
2019-10-23 2:56 ` 答复: " linfeilong
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=bf5c73b4b8534189be0f0df81fe863f0@huawei.com \
--to=linfeilong@huawei.com \
--cc=akpm@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).