From 0bbc2226d2874465e33140ecef1804e69eac13ab Mon Sep 17 00:00:00 2001 From: Suren Baghdasaryan Date: Wed, 3 Jun 2026 17:50:02 +0800 Subject: [PATCH] ANDROID: mm: fix cma_range_alloc retry logic Custom retry mechanism introduced in [1] resets area start location to 0 to restart the search. However a recent upstream change [2] overrides this start position. Bypass this override by directly jumping to the beginning of the loop. [1] https://android-review.googlesource.com/c/kernel/common/+/1431535 [2] 6972706f9592 ("mm/cma: refuse handing out non-contiguous page ranges") Bug: 519463493 Reported-by: yulijie1 Change-Id: Iaee1d5344ca4f5cb2172b7ff5c5257b1a4786c67 Signed-off-by: Suren Baghdasaryan --- mm/cma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/cma.c b/mm/cma.c index 20e34a470b98..e0e61e002835 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -804,6 +804,7 @@ static int cma_range_alloc(struct cma *cma, struct cma_memrange *cmr, goto out; for (start = 0; ; start = bitmap_no + mask + 1) { +retry: spin_lock_irq(&cma->lock); /* * If the request is larger than the available number @@ -835,7 +836,7 @@ static int cma_range_alloc(struct cma *cma, struct cma_memrange *cmr, ret = -ENOMEM; schedule_timeout_killable(msecs_to_jiffies(100)); num_attempts++; - continue; + goto retry; } else { spin_unlock_irq(&cma->lock); break;