summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2015-06-19 12:19:36 -0400
committerJens Axboe <axboe@fb.com>2015-06-19 12:19:36 -0400
commit9470e4a693db84bee7becbba8de01af02bb23c9f (patch)
tree9267bd9cd8d882e8996ba5b2df80ac4277909519 /block
parent4ceab71b9d84e55b59a76b54b2999dc377aae6e6 (diff)
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)
1714static int cfq_print_weight(struct seq_file *sf, void *v) 1714static int cfq_print_weight(struct seq_file *sf, void *v)
1715{ 1715{
1716 struct blkcg *blkcg = css_to_blkcg(seq_css(sf)); 1716 struct blkcg *blkcg = css_to_blkcg(seq_css(sf));
1717 struct cfq_group_data *cgd = blkcg_to_cfqgd(blkcg);
1718 unsigned int val = 0;
1717 1719
1718 seq_printf(sf, "%u\n", blkcg_to_cfqgd(blkcg)->weight); 1720 if (cgd)
1721 val = cgd->weight;
1722
1723 seq_printf(sf, "%u\n", val);
1719 return 0; 1724 return 0;
1720} 1725}
1721 1726
1722static int cfq_print_leaf_weight(struct seq_file *sf, void *v) 1727static int cfq_print_leaf_weight(struct seq_file *sf, void *v)
1723{ 1728{
1724 struct blkcg *blkcg = css_to_blkcg(seq_css(sf)); 1729 struct blkcg *blkcg = css_to_blkcg(seq_css(sf));
1730 struct cfq_group_data *cgd = blkcg_to_cfqgd(blkcg);
1731 unsigned int val = 0;
1732
1733 if (cgd)
1734 val = cgd->leaf_weight;
1725 1735
1726 seq_printf(sf, "%u\n", blkcg_to_cfqgd(blkcg)->leaf_weight); 1736 seq_printf(sf, "%u\n", val);
1727 return 0; 1737 return 0;
1728} 1738}
1729 1739