lkml.org 
[lkml]   [2019]   [Oct]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] scripts: fix memleak error in read_file
Date
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
\
 
 \ /
  Last update: 2019-10-22 13:49    [W:0.226 / U:0.224 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site