linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yue Hu <zbestahu@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: iamjoonsoo.kim@lge.com, labbott@redhat.com,
	rppt@linux.vnet.ibm.com, rdunlap@infradead.org,
	linux-mm@kvack.org, huyue2@yulong.com,
	Anshuman Khandual <anshuman.khandual@arm.com>
Subject: Re: [PATCH] mm/cma: Fix crash on CMA allocation if bitmap allocation fails
Date: Tue, 26 Mar 2019 09:59:25 +0800	[thread overview]
Message-ID: <20190326095925.0000186d.zbestahu@gmail.com> (raw)
In-Reply-To: <20190325151541.15350b039239ee9b331f3922@linux-foundation.org>

On Mon, 25 Mar 2019 15:15:41 -0700
Andrew Morton <akpm@linux-foundation.org> wrote:

> On Mon, 25 Mar 2019 16:13:09 +0800 Yue Hu <zbestahu@gmail.com> wrote:
> 
> > From: Yue Hu <huyue2@yulong.com>
> > 
> > A previous commit f022d8cb7ec7 ("mm: cma: Don't crash on allocation
> > if CMA area can't be activated") fixes the crash issue when activation
> > fails via setting cma->count as 0, same logic exists if bitmap
> > allocation fails.
> > 
> > --- a/mm/cma.c
> > +++ b/mm/cma.c
> > @@ -106,8 +106,10 @@ static int __init cma_activate_area(struct cma *cma)
> >  
> >  	cma->bitmap = kzalloc(bitmap_size, GFP_KERNEL);
> >  
> > -	if (!cma->bitmap)
> > +	if (!cma->bitmap) {
> > +		cma->count = 0;
> >  		return -ENOMEM;
> > +	}
> >  
> >  	WARN_ON_ONCE(!pfn_valid(pfn));
> >  	zone = page_zone(pfn_to_page(pfn));  
> 
> I'm unsure whether this is needed.
> 
> kmalloc() within __init code is generally considered to be a "can't
> fail".
> 
> If this was the only issue then I guess I'd take the patch if only for
> documentation/clarity purposes.  But cma_areas[] is in bss and is
> guaranteed to be all-zeroes, so I suspect this bug is a can't-happen. 

However, firstly cma->count will be assigned to size >> PAGE_SHIFT in
cma_init_reserved_mem().

> And we could revert f022d8cb7ec7 if we could be bothered (I can't).
> 
> 


      reply	other threads:[~2019-03-26  1:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-25  8:13 Yue Hu
2019-03-25 10:14 ` Anshuman Khandual
2019-03-25 22:15 ` Andrew Morton
2019-03-26  1:59   ` Yue Hu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190326095925.0000186d.zbestahu@gmail.com \
    --to=zbestahu@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=huyue2@yulong.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=labbott@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=rdunlap@infradead.org \
    --cc=rppt@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox