[PATCH] tools/bpf: Add missing fclose.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: zhang jiao <zhangjiao2@xxxxxxxxxxxxxxxxxxxx>

Cppcheck find a error as below:
	bpf_dbg.c:1397:2: error: Resource leak: fin [resourceLeak]
Add fclose to rm this error.

Signed-off-by: zhang jiao <zhangjiao2@xxxxxxxxxxxxxxxxxxxx>
---
 tools/bpf/bpf_dbg.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/bpf/bpf_dbg.c b/tools/bpf/bpf_dbg.c
index 00e560a17baf..5fb17fa0ace8 100644
--- a/tools/bpf/bpf_dbg.c
+++ b/tools/bpf/bpf_dbg.c
@@ -1394,5 +1394,11 @@ int main(int argc, char **argv)
 	if (argc >= 3)
 		fout = fopen(argv[2], "w");
 
-	return run_shell_loop(fin ? : stdin, fout ? : stdout);
+	run_shell_loop(fin ? : stdin, fout ? : stdout);
+
+	if (fin)
+		fclose(fin);
+	if (fout)
+		fclose(fout);
+	return 0;
 }
-- 
2.33.0







[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux