Skip to content

Commit

Permalink
blkcg: avoid free blkcg_root when failed to alloc blkcg policy
Browse files Browse the repository at this point in the history
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]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
weiping zhang authored and axboe committed Aug 25, 2017
1 parent 231b3db commit 4c18c9e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions block/blk-cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 4c18c9e

Please sign in to comment.