mm-damon-core-do-not-use-region-out-of-a-loop-in-damon_set_regions.patch removed from -mm tree
The quilt patch titled
Subject: mm/damon/core: do not use region out of a loop in damon_set_regions()
has been removed from the -mm tree. Its filename was
mm-damon-core-do-not-use-region-out-of-a-loop-in-damon_set_regions.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: SeongJae Park <[email protected]>
Subject: mm/damon/core: do not use region out of a loop in damon_set_regions()
Date: Fri, 22 May 2026 08:40:13 -0700
damon_set_regions() assumes the DAMON region iterator is referencing the last region after the region iteration loop is completed. The code is indeed implemented in the way, but that is not a documented safe behavior. Hence it is unreliable and difficult to read. Cleanup the code to avoid the case.
No behavioral change is intended.
---
mm/damon/core.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
mm/damon/core.c renamed from mm/damon/core.c~mm-damon-core-do-not-use-region-out-of-a-loop-in-damon_set_regions +9 -2
@@ -374,6 +374,7 @@ int damon_set_regions(struct damon_targefor (i =0 ; i < nr_ranges; i++) {struct damon_region *first =NULL , *last, *newr;struct damon_addr_range *range; +bool insert_before_r = false; range = &ranges[i];/* Get the first/last regions intersecting with the range */
@@ -383,8 +384,10 @@ int damon_set_regions(struct damon_targe first = r; last = r; } -if (r->ar.start >= range->end) +if (r->ar.start >= range->end) { + insert_before_r = true;break ; + } }if (!first) {/* no region intersects with this range */
@@ -394,7 +397,11 @@ int damon_set_regions(struct damon_targe ALIGN(range->end, min_region_sz));if (!newr)return -ENOMEM ; -damon_insert_region (newr,damon_prev_region (r), r, t); +if (insert_before_r) +damon_insert_region (newr,damon_prev_region (r), + r, t); +else +damon_add_region (newr, t); }else {/* resize intersecting regions to fit in this range */ first->ar.start = ALIGN_DOWN(range->start,
_
Patches currently in -mm which might be from [email protected] are
mm-damon-reclaim-handle-ctx-allocation-failure.patch mm-damonn-lru_sort-handle-ctx-allocation-failure.patch maintainers-add-testing-abi-documents-for-mm.patch