blkcg: add missing NULL check in ioc_cpd_alloc()
authorTejun Heo <tj@kernel.org>
Fri, 30 Aug 2019 13:10:58 +0000 (06:10 -0700)
committerJens Axboe <axboe@kernel.dk>
Fri, 30 Aug 2019 13:16:19 +0000 (07:16 -0600)
ioc_cpd_alloc() forgot to check NULL return from kzalloc().  Add it.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-iocost.c

index 9c8046a..2aae8ec 100644 (file)
@@ -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;
 }