Re: [PATCH] mm/damon/core: handle region split failure in apply_min_nr_regions()

From: SJ Park

Date: Sat Jul 18 2026 - 13:22:59 EST


On Sat, 18 Jul 2026 09:37:06 -0700 SJ Park <sj@xxxxxxxxxx> wrote:

> damon_apply_min_nr_regions() repeatedly split each region until its size
> becomes small enough to meet the user-defined low limit of the number of
> regions. The loop assumes the split operation (damon_split_region_at())
> will always succeed and create the new region. But the operation could
> silently fail for memory allocation failures, for example. If such
> failure happens and the region was the last region, the linked
> list-based next region fetching returns invalid pointer. As a result,
> invalid memory dereference and corruption could happen. Fix by breaking
> the loop in the corner case.

Sashiko found a room to improve in this patch. I will post a new revision with
the improvement. Please don't add this to mm-new.


Thanks,
SJ

[...]