[LTP] mremap07.c: New test for mremap() with MREMAP_DONTUNMAP
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Fri Apr 17 09:55:38 CEST 2026
Hi Wei,
On 2026-04-17, Wei Gao wrote:
> mremap07.c: New test for mremap() with MREMAP_DONTUNMAP
> Fixes: https://github.com/linux-test-project/ltp/issues/1168
Use Closes: for GitHub issue references. Fixes: is reserved for commit
SHA references in the form: Fixes: <hash> ("<subject>").
[...]
> +static void cleanup(void)
> +{
> + if (new_remap_addr && new_remap_addr != MAP_FAILED)
> + SAFE_MUNMAP(new_remap_addr, page_size);
> +
> + if (fault_addr && fault_addr != MAP_FAILED)
> + SAFE_MUNMAP(fault_addr, page_size);
> +
> + if (uffd != -1)
> + SAFE_CLOSE(uffd);
> +}
SAFE_MUNMAP does not clear the pointer. If setup() fails on a subsequent
iteration before SAFE_MMAP reassigns fault_addr, cleanup() will
double-munmap the stale pointer. Add fault_addr = NULL; after the
SAFE_MUNMAP call.
---
Note:
Our agent completed the review of the patch. The full review can be
found at: https://github.com/linux-test-project/ltp-agent/actions/runs/24554018117
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
More information about the ltp
mailing list