Skip to contentSkip to conversation

genalloc: Check result of devres_alloc()

PATCH New Jan Kara 1 participant 1 message Jan 21, 2015 Library code

lore
Share & tools
lore

Jan Kara

author
#0 lore raw

PATCH 1/1 genalloc: 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

---
 lib/genalloc.c | 2 ++
 1 file changed, 2 insertions(+)
lib/genalloc.c +2 -0
index 2e65d206b01c..094f8bee021f 100644
@@ -587,6 +587,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) {
Signature · 1 line
2.1.2