summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorweiping zhang <zhangweiping@didichuxing.com>2017-08-25 18:49:32 +0300
committerJens Axboe <axboe@kernel.dk>2017-08-25 22:51:07 +0300
commit4c18c9e962eb02e23731e5b40d4474fb04fdcb23 (patch)
tree2428fbbf84cf04811edcbf3baebc127711b45d20 /block
parent231b3db18d4be74e8b199916911c2c16db1790de (diff)
downloadlinux-4c18c9e962eb02e23731e5b40d4474fb04fdcb23.tar.xz
blkcg: avoid free blkcg_root when failed to alloc blkcg policy
this patch fix two errors, firstly avoid kfree blk_root, secondly not free(blkcg) ,if blkcg alloc fail(blkcg == NULL), just unlock that mutex; Signed-off-by: weiping zhang <zhangweiping@didichuxing.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/blk-cgroup.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 0480892e97e5..d3f56baee936 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -1067,7 +1067,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
blkcg = kzalloc(sizeof(*blkcg), GFP_KERNEL);
if (!blkcg) {
ret = ERR_PTR(-ENOMEM);
- goto free_blkcg;
+ goto unlock;
}
}
@@ -1111,8 +1111,10 @@ free_pd_blkcg:
for (i--; i >= 0; i--)
if (blkcg->cpd[i])
blkcg_policy[i]->cpd_free_fn(blkcg->cpd[i]);
-free_blkcg:
- kfree(blkcg);
+
+ if (blkcg != &blkcg_root)
+ kfree(blkcg);
+unlock:
mutex_unlock(&blkcg_pol_mutex);
return ret;
}