]> git.baikalelectronics.ru Git - kernel.git/commitdiff
samples/bpf: Fix fout leak in hbm's run_bpf_prog
authorHao Zeng <zenghao@kylinos.cn>
Tue, 11 Apr 2023 08:43:49 +0000 (16:43 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 30 May 2023 11:44:03 +0000 (12:44 +0100)
[ Upstream commit 23acb14af1914010dd0aae1bbb7fab28bf518b8e ]

Fix fout being fopen'ed but then not subsequently fclose'd. In the affected
branch, fout is otherwise going out of scope.

Signed-off-by: Hao Zeng <zenghao@kylinos.cn>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20230411084349.1999628-1-zenghao@kylinos.cn
Signed-off-by: Sasha Levin <sashal@kernel.org>
samples/bpf/hbm.c

index e0fbab9bec83e14347d0330f8f7bad1b14db1b33..6d6d4e4ea8437bad50e4d419d2d5d0e8abaa90cd 100644 (file)
@@ -307,6 +307,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 -