[PATCH] tools/bpf: Add missing fclose.
From: zhangjiao2
Date: Thu Sep 12 2024 - 04:58:49 EST
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