]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
blkcg: use blkg_free() in blkcg_init_queue() failure path
authorTejun Heo <tj@kernel.org>
Tue, 18 Aug 2015 21:55:07 +0000 (14:55 -0700)
committerJens Axboe <axboe@fb.com>
Tue, 18 Aug 2015 22:49:16 +0000 (15:49 -0700)
When blkcg_init_queue() fails midway after creating a new blkg, it
performs kfree() directly; however, this doesn't free the policy data
areas.  Make it use blkg_free() instead.  In turn, blkg_free() is
updated to handle root request_list special case.

While this fixes a possible memory leak, it's on an unlikely failure
path of an already cold path and the size leaked per occurrence is
miniscule too.  I don't think it needs to be tagged for -stable.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-cgroup.c

index 1db904f955023f5783810bf6966022f462038625..cd251830038a6066d80176e0382552dd6d25b1d1 100644 (file)
@@ -70,7 +70,8 @@ static void blkg_free(struct blkcg_gq *blkg)
        for (i = 0; i < BLKCG_MAX_POLS; i++)
                kfree(blkg->pd[i]);
 
-       blk_exit_rl(&blkg->rl);
+       if (blkg->blkcg != &blkcg_root)
+               blk_exit_rl(&blkg->rl);
        kfree(blkg);
 }
 
@@ -938,7 +939,7 @@ int blkcg_init_queue(struct request_queue *q)
                radix_tree_preload_end();
 
        if (IS_ERR(blkg)) {
-               kfree(new_blkg);
+               blkg_free(new_blkg);
                return PTR_ERR(blkg);
        }