All of lore.kernel.org
 help / color / mirror / Atom feed
From: Levi Yun <ppbuk5246@gmail.com>
To: rppt@kernel.org, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Levi Yun <ppbuk5246@gmail.com>
Subject: [PATCH] [PATCH] memblock: Fix return sizeless candidate on __memblock_find_range_top_down.
Date: Wed,  4 Jan 2023 18:50:49 +0900	[thread overview]
Message-ID: <20230104095049.59043-1-ppbuk5246@gmail.com> (raw)

__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.

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


             reply	other threads:[~2023-01-04  9:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-04  9:50 Levi Yun [this message]
2023-01-04 10:24 ` [PATCH] [PATCH] memblock: Fix return sizeless candidate on __memblock_find_range_top_down Mike Rapoport
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=20230104095049.59043-1-ppbuk5246@gmail.com \
    --to=ppbuk5246@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rppt@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.