[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240912081730.22094-1-zhangjiao2@cmss.chinamobile.com>
Date: Thu, 12 Sep 2024 16:17:30 +0800
From: zhangjiao2 <zhangjiao2@...s.chinamobile.com>
To: ast@...nel.org
Cc: daniel@...earbox.net,
andrii@...nel.org,
bpf@...r.kernel.org,
linux-kernel@...r.kernel.org,
zhang jiao <zhangjiao2@...s.chinamobile.com>
Subject: [PATCH] tools/bpf: Add missing fclose.
From: zhang jiao <zhangjiao2@...s.chinamobile.com>
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@...s.chinamobile.com>
---
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
Powered by blists - more mailing lists