Re: [PATCH] selftests/x86/lam: fix memory leak and resource leak in lam.c

Peter Zijlstra
2025-03-24T12:51:18Z

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.