X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=block%2Fblk-cgroup.c;h=8c4e81ac5e75432c1e29917dd6bf0305505ad7a6;hb=f399038b276db24cccb6f97654214ba81c2d09a5;hp=b95219d2168d0957eb2a537c920cac531d7238d7;hpb=35dfcefb1a05f270bea4e62844799286b4eb6b91;p=firefly-linux-kernel-4.4.55.git diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index b95219d2168d..8c4e81ac5e75 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -720,8 +720,12 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, return -EINVAL; disk = get_gendisk(MKDEV(major, minor), &part); - if (!disk || part) + if (!disk) return -EINVAL; + if (part) { + put_disk(disk); + return -EINVAL; + } rcu_read_lock(); spin_lock_irq(disk->queue->queue_lock); @@ -876,6 +880,13 @@ void blkcg_drain_queue(struct request_queue *q) { lockdep_assert_held(q->queue_lock); + /* + * @q could be exiting and already have destroyed all blkgs as + * indicated by NULL root_blkg. If so, don't confuse policies. + */ + if (!q->root_blkg) + return; + /* * @q could be exiting and already have destroyed all blkgs as * indicated by NULL root_blkg. If so, don't confuse policies.