Re: [PATCH] selftests/mm: Fix BUG_ON checking wrong variable in mremap_dontunmap

From: SJ Park

Date: Fri Jul 17 2026 - 20:00:16 EST


On Fri, 17 Jul 2026 15:02:51 +0800 Hongfu Li <hongfu.li@xxxxxxxxx> wrote:

> From: Hongfu Li <lihongfu@xxxxxxxxxx>
>
> In mremap_dontunmap_partial_mapping_overwrite(), mremap() stores its
> returned remapped address into remapped_mapping, while the BUG_ON
> incorrectly checks dest_mapping instead.
>
> If mremap() fails, dest_mapping still holds a valid pointer obtained from
> the prior mmap() call, making this BUG_ON never trigger at all. Correct
> the check to validate the actual mremap() return value stored in
> remapped_mapping.

Nice catch.

>
> Signed-off-by: Hongfu Li <lihongfu@xxxxxxxxxx>

Reviewed-by: SJ Park <sj@xxxxxxxxxx>


Thanks,
SJ

[...]