[PATCH] samples/bpf:fix fout leak

From: Hao Zeng
Date: Tue Apr 11 2023 - 04:44:03 EST


Fix fout fopen but not fclose

Signed-off-by: Hao Zeng <zenghao@xxxxxxxxxx>
---
samples/bpf/hbm.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/samples/bpf/hbm.c b/samples/bpf/hbm.c
index 516fbac28b71..7f89700a17b6 100644
--- a/samples/bpf/hbm.c
+++ b/samples/bpf/hbm.c
@@ -315,6 +315,7 @@ static int run_bpf_prog(char *prog, int cg_id)
fout = fopen(fname, "w");
fprintf(fout, "id:%d\n", cg_id);
fprintf(fout, "ERROR: Could not lookup queue_stats\n");
+ fclose(fout);
} else if (stats_flag && qstats.lastPacketTime >
qstats.firstPacketTime) {
long long delta_us = (qstats.lastPacketTime -
--
2.37.2


No virus found
Checked by Hillstone Network AntiVirus