linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Levi Yun <ppbuk5246@gmail.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [PATCH] memblock: Fix return sizeless candidate on __memblock_find_range_top_down.
Date: Wed, 4 Jan 2023 12:24:34 +0200	[thread overview]
Message-ID: <Y7VT4gvLCQK7B1Ak@kernel.org> (raw)
In-Reply-To: <20230104095049.59043-1-ppbuk5246@gmail.com>

On Wed, Jan 04, 2023 at 06:50:49PM +0900, Levi Yun wrote:
> __memblock_find_range_top_down can return start address of free region
> which sizeless then user speicified.
> To prevent the above case, add size check on candidate free region.

Did you see an actual issue or it's solely based on code inspection?
 
> Signed-off-by: Levi Yun <ppbuk5246@gmail.com>
> ---
>  mm/memblock.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/memblock.c b/mm/memblock.c
> index 511d4783dcf1..710e2ef8d67d 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -262,7 +262,7 @@ __memblock_find_range_top_down(phys_addr_t start, phys_addr_t end,
>  			continue;
>  
>  		cand = round_down(this_end - size, align);
> -		if (cand >= this_start)
> +		if (cand >= this_start && this_end - cand >= size)
>  			return cand;
>  	}
>  
> -- 
> 2.35.1
> 

-- 
Sincerely yours,
Mike.


  reply	other threads:[~2023-01-04 10:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-04  9:50 Levi Yun
2023-01-04 10:24 ` Mike Rapoport [this message]
2023-01-04 10:33   ` Yun Levi
2023-01-04 10:46     ` Mike Rapoport
2023-01-04 21:13       ` Yun Levi

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=Y7VT4gvLCQK7B1Ak@kernel.org \
    --to=rppt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ppbuk5246@gmail.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