blk-throttle: check stats_cpu before reading it from sysfs
Thadeu Lima de Souza Cascardo authored
When reading blkio.throttle.io_serviced in a recently created blkio
cgroup, it's possible to race against the creation of a throttle policy,
which delays the allocation of stats_cpu.

Like other functions in the throttle code, just checking for a NULL
stats_cpu prevents the following oops caused by that race.

[ 1117.285199] Unable to handle kernel paging request for data at address 0x7fb4d0020
[ 1117.285252] Faulting instruction address: 0xc0000000003efa2c
[ 1137.733921] Oops: Kernel access of bad area, sig: 11 [#1]
[ 1137.733945] SMP NR_CPUS=2048 NUMA PowerNV
[ 1137.734025] Modules linked in: bridge stp llc kvm_hv kvm binfmt_misc autofs4
[ 1137.734102] CPU: 3 PID: 5302 Comm: blkcgroup Not tainted 3.19.0 #5
[ 1137.734132] task: c000000f1d188b00 ti: c000000f1d210000 task.ti: c000000f1d210000
[ 1137.734167] NIP: c0000000003efa2c LR: c0000000003ef9f0 CTR: c0000000003ef980
[ 1137.734202] REGS: c000000f1d213500 TRAP: 0300   Not tainted  (3.19.0)
[ 113...
045c47ca
Name Last commit Last update
..
partitions Merge branch 'for-3.20/core' of git://git.kernel.dk/linux-block
Kconfig block: Add T10 Protection Information functions
Kconfig.iosched blkcg: make CONFIG_BLK_CGROUP bool
Makefile block: Add T10 Protection Information functions
bio-integrity.c block: fix regression where bio_integrity_process uses wrong bio_vec iterator
bio.c block: rewrite and split __bio_copy_iov()
blk-cgroup.c blkcg: remove blkcg->id
blk-cgroup.h blkcg: remove blkcg->id
blk-core.c Merge branch 'for-3.20/core' of git://git.kernel.dk/linux-block
blk-exec.c blk-mq: avoid infinite recursion with the FUA flag
blk-flush.c blk-mq: support per-distpatch_queue flush machinery
blk-integrity.c block: Don't merge requests if integrity flags differ
blk-ioc.c block: Substitute rcu_access_pointer() for rcu_dereference_raw()
blk-iopoll.c Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip into next
blk-lib.c block: Quiesce zeroout wrapper
blk-map.c block: handle the null_mapped flag correctly in blk_rq_map_user_iov
blk-merge.c block: remove unused function blk_bio_map_sg
blk-mq-cpu.c blk-mq: add file comments and update copyright notices
blk-mq-cpumap.c blk-mq: Use all available hardware queues
blk-mq-sysfs.c Revert "blk-mq: fix hctx/ctx kobject use-after-free"
blk-mq-tag.c blk-mq: fix double-free in error path
blk-mq-tag.h blk-mq: add tag allocation policy
blk-mq.c Merge branch 'for-3.20/core' of git://git.kernel.dk/linux-block
blk-mq.h blk-mq: release mq's kobjects in blk_release_queue()
blk-settings.c block: remove artifical max_hw_sectors cap
blk-softirq.c
blk-sysfs.c
blk-tag.c
blk-throttle.c
blk-timeout.c
blk.h
bounce.c
bsg-lib.c
bsg.c
cfq-iosched.c
cmdline-parser.c
compat_ioctl.c
deadline-iosched.c
elevator.c
genhd.c
ioctl.c
ioprio.c
noop-iosched.c
partition-generic.c
scsi_ioctl.c
t10-pi.c