提交 9470e4a6 编写于 作者: J Jens Axboe

cfq-iosched: fix sysfs oops when attempting to read unconfigured weights

If none of the devices in the system are using CFQ, then attempting to
read:

/sys/fs/cgroup/blkio/blkio.leaf_weight

will results in a NULL dereference. Check for a valid cfq_group_data
struct before attempting to dereference it.
Reported-by: NAndrey Wagin <avagin@gmail.com>
Fixes: e48453c3 ("block, cgroup: implement policy-specific per-blkcg data")
Signed-off-by: NJens Axboe <axboe@fb.com>
上级 4ceab71b
......@@ -1714,16 +1714,26 @@ static int cfqg_print_leaf_weight_device(struct seq_file *sf, void *v)
static int cfq_print_weight(struct seq_file *sf, void *v)
{
struct blkcg *blkcg = css_to_blkcg(seq_css(sf));
struct cfq_group_data *cgd = blkcg_to_cfqgd(blkcg);
unsigned int val = 0;
seq_printf(sf, "%u\n", blkcg_to_cfqgd(blkcg)->weight);
if (cgd)
val = cgd->weight;
seq_printf(sf, "%u\n", val);
return 0;
}
static int cfq_print_leaf_weight(struct seq_file *sf, void *v)
{
struct blkcg *blkcg = css_to_blkcg(seq_css(sf));
struct cfq_group_data *cgd = blkcg_to_cfqgd(blkcg);
unsigned int val = 0;
if (cgd)
val = cgd->leaf_weight;
seq_printf(sf, "%u\n", blkcg_to_cfqgd(blkcg)->leaf_weight);
seq_printf(sf, "%u\n", val);
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册