Re: [PATCH] mm/cma: fix reserved page leak on activation failure
From: Oscar Salvador (SUSE)
Date: Tue May 26 2026 - 07:51:53 EST
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, 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