linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scripts: fix memleak error in read_file
@ 2019-10-22 11:47 linfeilong
  2019-10-22 22:13 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: linfeilong @ 2019-10-22 11:47 UTC (permalink / raw)
  To: akpm, linux-kernel

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-10-23  2:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-22 11:47 [PATCH] scripts: fix memleak error in read_file linfeilong
2019-10-22 22:13 ` Andrew Morton
2019-10-23  2:56   ` 答复: " linfeilong

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