Re: [PATCH] mm/cma: fix reserved page leak on activation failure

From: Usama Arif

Date: Tue May 26 2026 - 09:03:29 EST




On 26/05/2026 13:44, Muchun Song wrote:
>
>
>> On May 26, 2026, at 19:51, Oscar Salvador (SUSE) <osalvador@xxxxxxxxxx> wrote:
>>
>> On Tue, May 26, 2026 at 04:30:03AM -0700, Usama Arif wrote:
>>> On Fri, 22 May 2026 14:26:58 +0800 Muchun Song <songmuchun@xxxxxxxxxxxxx> wrote:
>> ...
>>>> diff --git a/mm/cma.c b/mm/cma.c
>>>> index c7ca567f4c5c..a30075507d41 100644
>>>> --- a/mm/cma.c
>>>> +++ b/mm/cma.c
>>>> @@ -188,10 +188,13 @@ static void __init cma_activate_area(struct cma *cma)
>>>>
>>>> /* Expose all pages to the buddy, they are useless for CMA. */
>>>> if (!test_bit(CMA_RESERVE_PAGES_ON_ERROR, &cma->flags)) {
>>>> - for (r = 0; r < allocrange; r++) {
>>>> + for (r = 0; r < cma->nranges; r++) {
>>>> + unsigned long start_pfn;
>>>> +
>>>> cmr = &cma->ranges[r];
>>>> + start_pfn = r < allocrange ? early_pfn[r] : cmr->early_pfn;
>>>
>>> Should this be r <= allocrange?
>
> Yes. So I sent a v2 to fix it last Saturday.
>
> https://lore.kernel.org/linux-mm/20260523060123.2207992-1-songmuchun@xxxxxxxxxxxxx/
>
> Thanks.

Ah still catching up on the mailing list. Thanks!

>
>>
>> Yes, I think you are right. I missed that.
>>
>> early_pfn[alloc_range] holds the last assignment, so we should start
>> from the next one reading cmr->early_pfn.
>>
>>
>>
>> --
>> Oscar Salvador
>> SUSE Labs