blkcg: avoid free blkcg_root when failed to alloc blkcg policy
Subsystems (2)
PATCH 1/1 blkcg: avoid free blkcg_root when failed to alloc blkcg policy
this patch fix two errors, firstly avoid kfree blk_root, secondly not free(blkcg) ,if blkcg alloc fail(blkcg == NULL), just unlock that mutex;
Signed-off-by weiping zhang <[email protected]>
--- block/blk-cgroup.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
block/blk-cgroup.c +5 -3
@@ -1067,7 +1067,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css) blkcg =kzalloc (sizeof (*blkcg),GFP_KERNEL );if (!blkcg) { ret =ERR_PTR (-ENOMEM ); - goto free_blkcg; + goto unlock; } }
@@ -1111,8 +1111,10 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)for (i--; i >=0 ; i--)if (blkcg->cpd[i]) blkcg_policy[i]->cpd_free_fn (blkcg->cpd[i]); -free_blkcg: -kfree (blkcg); + +if (blkcg != &blkcg_root) +kfree (blkcg); +unlock:mutex_unlock (&blkcg_pol_mutex);return ret; }
Signature · 1 line
2.9.4
Jens Axboe
maintainerQuoted 2 lines · weiping zhang
this patch fix two errors, firstly avoid kfree
blk_root, secondly not free(blkcg) ,if blkcg alloc fail(blkcg == NULL), just unlock that mutex;
Looks good, applied.
Signature · 1 line
Jens Axboe