mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] lib/genalloc.c: fix the end addr check in addr_in_gen_pool()
@ 2014-12-19  2:30 Toshi Kikuchi
  2014-12-22 21:05 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Toshi Kikuchi @ 2014-12-19  2:30 UTC (permalink / raw)
  To: linux-kernel

Since chunk->end_addr is (chunk->start_addr + size - 1),
the end address to compare should be (start + size - 1).

Signed-off-by: Toshi Kikuchi <toshik@chromium.org>
---
 lib/genalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/genalloc.c b/lib/genalloc.c
index 2e65d20..42a95e9 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -415,7 +415,7 @@ bool addr_in_gen_pool(struct gen_pool *pool, unsigned long start,
 			size_t size)
 {
 	bool found = false;
-	unsigned long end = start + size;
+	unsigned long end = start + size - 1;
 	struct gen_pool_chunk *chunk;
 
 	rcu_read_lock();
-- 
2.2.0.rc0.207.ga3a616c


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] lib/genalloc.c: fix the end addr check in addr_in_gen_pool()
  2014-12-19  2:30 [PATCH] lib/genalloc.c: fix the end addr check in addr_in_gen_pool() Toshi Kikuchi
@ 2014-12-22 21:05 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2014-12-22 21:05 UTC (permalink / raw)
  To: Toshi Kikuchi; +Cc: linux-kernel

On Thu, 18 Dec 2014 18:30:59 -0800 Toshi Kikuchi <toshik@chromium.org> wrote:

> Since chunk->end_addr is (chunk->start_addr + size - 1),
> the end address to compare should be (start + size - 1).
> 
> Signed-off-by: Toshi Kikuchi <toshik@chromium.org>
> ---
>  lib/genalloc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/genalloc.c b/lib/genalloc.c
> index 2e65d20..42a95e9 100644
> --- a/lib/genalloc.c
> +++ b/lib/genalloc.c
> @@ -415,7 +415,7 @@ bool addr_in_gen_pool(struct gen_pool *pool, unsigned long start,
>  			size_t size)
>  {
>  	bool found = false;
> -	unsigned long end = start + size;
> +	unsigned long end = start + size - 1;
>  	struct gen_pool_chunk *chunk;
>  
>  	rcu_read_lock();

urgh.  gen_pool_chunk.end_addr should have been made exclusive, not
inclusive.  Or switch to start_addr/size.  The code would be
considerably nicer that way.

And the struct gen_pool_chunk definition should be moved into
genalloc.c.  I'm not sure what drivers/acpi/apei/ghes.c is doing
fiddling around with genalloc internals, but it should stop doing it.

Sigh :(

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-12-22 21:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-19  2:30 [PATCH] lib/genalloc.c: fix the end addr check in addr_in_gen_pool() Toshi Kikuchi
2014-12-22 21:05 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®