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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAE2+fR_kG1SpE3DZ6cbZL+J8HT25RcaGxYrZP-H+rDFSJG6sdQ@mail.gmail.com>
Date: Tue, 25 Mar 2025 15:26:58 +0530
From: malaya kumar rout <malayarout91@...il.com>
To: Ingo Molnar <mingo@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>, Thomas Gleixner <tglx@...utronix.de>, 
	Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>, 
	Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org, 
	"H. Peter Anvin" <hpa@...or.com>, Shuah Khan <shuah@...nel.org>, linux-kernel@...r.kernel.org, 
	linux-kselftest@...r.kernel.org
Subject: Re: [PATCH] selftests/x86/lam: fix memory leak and resource leak in lam.c

I appreciate all the feedback and recommendations provided. We will
incorporate the same.

Thanks & Regards,
Malaya Kumar Rout

On Tue, Mar 25, 2025 at 2:59 PM Ingo Molnar <mingo@...nel.org> wrote:
>
>
> * Peter Zijlstra <peterz@...radead.org> wrote:
>
> > On Mon, Mar 24, 2025 at 06:17:50PM +0530, Malaya Kumar Rout wrote:
> > > Static Analyis for bench_htab_mem.c with cppcheck:error
> > > tools/testing/selftests/x86/lam.c:585:3:
> > > error: Resource leak: file_fd [resourceLeak]
> > > tools/testing/selftests/x86/lam.c:593:3:
> > > error: Resource leak: file_fd [resourceLeak]
> > > tools/testing/selftests/x86/lam.c:600:3:
> > > error: Memory leak: fi [memleak]
> > > tools/testing/selftests/x86/lam.c:1066:2:
> > > error: Resource leak: fd [resourceLeak]
> > >
> > > fix the issue by closing the file descriptors and
> > > releasing the allocated memory.
> > >
> >
> > But but but, doesn't the program just exit on any of those 'errors'
> > anyway?
> >
> > That is, iirc this is a single shot program.
>
> While that's true, still proper cleanup of resources is a good practice
> - and in more complicated tools it's useful to fix even these
> semi-false-positives, to make sure other warnings don't get missed.
>
> Having said that, the error/cleanup control flow here doesn't look
> overly clean here to begin with, so I'd suggest fixing that (with goto
> labels or such) - which would fix the file_fd 'leak' as a happy side
> effect.
>
> Thanks,
>
>         Ingo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ