Skip to contentSkip to conversation

blkcg: add missing NULL check in ioc_cpd_alloc()

PATCH Applied Tejun Heo 2 participants 2 messages Aug 30, 2019

Subsystems (2)
lore
Share & tools
lore

Tejun Heo

author maintainer
#0 lore raw

PATCH 1/1 blkcg: add missing NULL check in ioc_cpd_alloc()

ioc_cpd_alloc() forgot to check NULL return from kzalloc(). Add it.

---
 block/blk-iocost.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
block/blk-iocost.c +3 -1
index 9c8046ac5925..2aae8ec391ef 100644
@@ -1888,8 +1888,10 @@ static struct blkcg_policy_data *ioc_cpd_alloc(gfp_t gfp)
 	struct ioc_cgrp *iocc;
 
 	iocc = kzalloc(sizeof(struct ioc_cgrp), gfp);
-	iocc->dfl_weight = CGROUP_WEIGHT_DFL;
+	if (!iocc)
+		return NULL;
 
+	iocc->dfl_weight = CGROUP_WEIGHT_DFL;
 	return &iocc->cpd;
 }
 
maintainer Applied
#1 lore raw
Quoted 1 line · Tejun Heo

ioc_cpd_alloc() forgot to check NULL return from kzalloc(). Add it.

Applied, thanks.

Signature · 1 line
Jens Axboe