From: Tejun Heo tj@kernel.org
mainline inclusion from mainline-5.4-rc1 commit e916ad29d96485e5aa3d3237bfeab1522c713d5e category: feature bugzilla: 38688 CVE: NA
---------------------------
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 Signed-off-by: Yu Kuai yukuai3@huawei.com Reviewed-by: Hou Tao houtao1@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- block/blk-iocost.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/block/blk-iocost.c b/block/blk-iocost.c index b542f6581814e..afcb3aa3f75d9 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -1889,8 +1889,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; }