summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2015-06-19 10:19:36 -0600
committerJens Axboe <axboe@fb.com>2015-06-19 10:19:36 -0600
commit9470e4a693db84bee7becbba8de01af02bb23c9f (patch)
tree9267bd9cd8d882e8996ba5b2df80ac4277909519 /block
parent4ceab71b9d84e55b59a76b54b2999dc377aae6e6 (diff)
downloadlwn-9470e4a693db84bee7becbba8de01af02bb23c9f.tar.gz
lwn-9470e4a693db84bee7becbba8de01af02bb23c9f.zip
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: Andrey Wagin <avagin@gmail.com> Fixes: e48453c3 ("block, cgroup: implement policy-specific per-blkcg data") Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block')
-rw-r--r--block/cfq-iosched.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index dbd0207928fb..ed86fb242cd4 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -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;
}