From ad3d5d2f7deca6d0fd72163573bcb0cca6337e33 Mon Sep 17 00:00:00 2001 From: Toshi Kikuchi Date: Thu, 12 Feb 2015 15:02:18 -0800 Subject: lib/genalloc.c: fix the end addr check in addr_in_gen_pool() 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 Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- lib/genalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/genalloc.c') diff --git a/lib/genalloc.c b/lib/genalloc.c index 2e65d206b01c..42a95e99b754 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(); -- cgit From 18fa6d2e4574d2a44e0c2cc5ae1c1812ec8019d8 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 12 Feb 2015 15:02:46 -0800 Subject: lib/genalloc.c: remove redundant include Removing this include produces byte-identical output, and thus removes a false dependency. Signed-off-by: Rasmus Villemoes Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- lib/genalloc.c | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/genalloc.c') diff --git a/lib/genalloc.c b/lib/genalloc.c index 42a95e99b754..0fe1cbe87700 100644 --- a/lib/genalloc.c +++ b/lib/genalloc.c @@ -34,7 +34,6 @@ #include #include #include -#include #include static inline size_t chunk_size(const struct gen_pool_chunk *chunk) -- cgit From 310ee9e8f370f8fd7a76856726aea88839bb0f8f Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Fri, 13 Feb 2015 14:36:47 -0800 Subject: lib/genalloc.c: check result of devres_alloc() devm_gen_pool_create() calls devres_alloc() and dereferences its result without checking whether devres_alloc() succeeded. Check for error and bail out if it happened. Coverity-id 1016493. Signed-off-by: Jan Kara Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- lib/genalloc.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/genalloc.c') diff --git a/lib/genalloc.c b/lib/genalloc.c index 0fe1cbe87700..d214866eeea2 100644 --- a/lib/genalloc.c +++ b/lib/genalloc.c @@ -586,6 +586,8 @@ struct gen_pool *devm_gen_pool_create(struct device *dev, int min_alloc_order, struct gen_pool **ptr, *pool; ptr = devres_alloc(devm_gen_pool_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return NULL; pool = gen_pool_create(min_alloc_order, nid); if (pool) { -- cgit