提交 ae994ea9 编写于 作者: J Jens Axboe

cfq-iosched: fix other locations where blkcg_to_cfqgd() can return NULL

Commit 9470e4a6 only covered the initial bug report, there are
other spots in CFQ where we need to check that we actually have
a valid cfq_group_data structure.

Fixes: e48453c3 ("block, cgroup: implement policy-specific per-blkcg data")
Signed-off-by: NJens Axboe <axboe@fb.com>
上级 9470e4a6
...@@ -1754,6 +1754,9 @@ static ssize_t __cfqg_set_weight_device(struct kernfs_open_file *of, ...@@ -1754,6 +1754,9 @@ static ssize_t __cfqg_set_weight_device(struct kernfs_open_file *of,
ret = -EINVAL; ret = -EINVAL;
cfqg = blkg_to_cfqg(ctx.blkg); cfqg = blkg_to_cfqg(ctx.blkg);
cfqgd = blkcg_to_cfqgd(blkcg); cfqgd = blkcg_to_cfqgd(blkcg);
if (!cfqg || !cfqgd)
goto err;
if (!ctx.v || (ctx.v >= CFQ_WEIGHT_MIN && ctx.v <= CFQ_WEIGHT_MAX)) { if (!ctx.v || (ctx.v >= CFQ_WEIGHT_MIN && ctx.v <= CFQ_WEIGHT_MAX)) {
if (!is_leaf_weight) { if (!is_leaf_weight) {
cfqg->dev_weight = ctx.v; cfqg->dev_weight = ctx.v;
...@@ -1765,6 +1768,7 @@ static ssize_t __cfqg_set_weight_device(struct kernfs_open_file *of, ...@@ -1765,6 +1768,7 @@ static ssize_t __cfqg_set_weight_device(struct kernfs_open_file *of,
ret = 0; ret = 0;
} }
err:
blkg_conf_finish(&ctx); blkg_conf_finish(&ctx);
return ret ?: nbytes; return ret ?: nbytes;
} }
...@@ -1787,12 +1791,17 @@ static int __cfq_set_weight(struct cgroup_subsys_state *css, struct cftype *cft, ...@@ -1787,12 +1791,17 @@ static int __cfq_set_weight(struct cgroup_subsys_state *css, struct cftype *cft,
struct blkcg *blkcg = css_to_blkcg(css); struct blkcg *blkcg = css_to_blkcg(css);
struct blkcg_gq *blkg; struct blkcg_gq *blkg;
struct cfq_group_data *cfqgd; struct cfq_group_data *cfqgd;
int ret = 0;
if (val < CFQ_WEIGHT_MIN || val > CFQ_WEIGHT_MAX) if (val < CFQ_WEIGHT_MIN || val > CFQ_WEIGHT_MAX)
return -EINVAL; return -EINVAL;
spin_lock_irq(&blkcg->lock); spin_lock_irq(&blkcg->lock);
cfqgd = blkcg_to_cfqgd(blkcg); cfqgd = blkcg_to_cfqgd(blkcg);
if (!cfqgd) {
ret = -EINVAL;
goto out;
}
if (!is_leaf_weight) if (!is_leaf_weight)
cfqgd->weight = val; cfqgd->weight = val;
...@@ -1814,8 +1823,9 @@ static int __cfq_set_weight(struct cgroup_subsys_state *css, struct cftype *cft, ...@@ -1814,8 +1823,9 @@ static int __cfq_set_weight(struct cgroup_subsys_state *css, struct cftype *cft,
} }
} }
out:
spin_unlock_irq(&blkcg->lock); spin_unlock_irq(&blkcg->lock);
return 0; return ret;
} }
static int cfq_set_weight(struct cgroup_subsys_state *css, struct cftype *cft, static int cfq_set_weight(struct cgroup_subsys_state *css, struct cftype *cft,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册