Skip to content

Commit

Permalink
blkcg: fix blkg_alloc() failure path
Browse files Browse the repository at this point in the history
When policy data allocation fails in the middle, blkg_alloc() invokes
blkg_free() to destroy the half constructed blkg.  This ends up
calling pd_exit_fn() on policy datas which didn't go through
pd_init_fn().  Fix it by making blkg_alloc() call pd_init_fn()
immediately after each policy data allocation.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Tejun Heo authored and Jens Axboe committed Jun 4, 2012
1 parent ffea73f commit 9b2ea86
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions block/blk-cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,8 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct request_queue *q)

blkg->pd[i] = pd;
pd->blkg = blkg;
}

/* invoke per-policy init */
for (i = 0; i < BLKCG_MAX_POLS; i++) {
struct blkcg_policy *pol = blkcg_policy[i];

/* invoke per-policy init */
if (blkcg_policy_enabled(blkg->q, pol))
pol->pd_init_fn(blkg);
}
Expand Down

0 comments on commit 9b2ea86

Please sign in to comment.