From: Jan Kara Date: Fri, 13 Feb 2015 22:36:47 +0000 (-0800) Subject: lib/genalloc.c: check result of devres_alloc() X-Git-Tag: v4.9.8~4813^2~90 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=310ee9e8f370f8fd7a76856726aea88839bb0f8f;p=platform%2Fkernel%2Flinux-rpi3.git 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 --- diff --git a/lib/genalloc.c b/lib/genalloc.c index 0fe1cbe..d214866 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) {