lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAADnVQJbzjt0w158Ww2PBJvrzwVbUeCq7O_HHyVfKvZa3UC4_g@mail.gmail.com>
Date: Fri, 13 Sep 2024 17:02:03 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: zhangjiao2 <zhangjiao2@...s.chinamobile.com>
Cc: Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>, 
	Andrii Nakryiko <andrii@...nel.org>, bpf <bpf@...r.kernel.org>, 
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] tools/bpf: Add missing fclose.

On Thu, Sep 12, 2024 at 1:58 AM zhangjiao2
<zhangjiao2@...s.chinamobile.com> wrote:
>
> 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;

main() is about to exit. There is really no need to close it explicitly.

pw-bot: cr

Daniel,

is this debugger still useful?
Should we remove it?
and bpf_jit_disasm.c too ?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ