Re: [PATCH v2] selftests/x86/lam: fix resource leak in do_uring() and allocate_dsa_pasid()

Ingo Molnar
2025-04-07T18:20:11Z

* Malaya Kumar Rout <malayarout91@gmail.com> wrote:

> @@ -1189,9 +1191,10 @@ void *allocate_dsa_pasid(void)
>
> wq = mmap(NULL, 0x1000, PROT_WRITE,
> MAP_SHARED | MAP_POPULATE, fd, 0);
> - if (wq == MAP_FAILED)
> + if (wq == MAP_FAILED){
> + close(fd);
> perror("mmap");

We should unconditionally close 'fd' after the mmap() call, not just in
the perror() branch.

Thanks,

Ingo