Commit b5a9adcb authored by Waiman Long's avatar Waiman Long Committed by Jens Axboe

blk-cgroup: Return -ENOMEM directly in blkcg_css_alloc() error path

For blkcg_css_alloc(), the only error that will be returned is -ENOMEM.
Simplify error handling code by returning this error directly instead
of setting an intermediate "ret" variable.
Signed-off-by: default avatarWaiman Long <longman@redhat.com>
Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
Acked-by: default avatarTejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/20221105005902.407297-2-longman@redhat.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 077a4033
...@@ -1139,7 +1139,6 @@ static struct cgroup_subsys_state * ...@@ -1139,7 +1139,6 @@ static struct cgroup_subsys_state *
blkcg_css_alloc(struct cgroup_subsys_state *parent_css) blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
{ {
struct blkcg *blkcg; struct blkcg *blkcg;
struct cgroup_subsys_state *ret;
int i; int i;
mutex_lock(&blkcg_pol_mutex); mutex_lock(&blkcg_pol_mutex);
...@@ -1148,10 +1147,8 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css) ...@@ -1148,10 +1147,8 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
blkcg = &blkcg_root; blkcg = &blkcg_root;
} else { } else {
blkcg = kzalloc(sizeof(*blkcg), GFP_KERNEL); blkcg = kzalloc(sizeof(*blkcg), GFP_KERNEL);
if (!blkcg) { if (!blkcg)
ret = ERR_PTR(-ENOMEM);
goto unlock; goto unlock;
}
} }
for (i = 0; i < BLKCG_MAX_POLS ; i++) { for (i = 0; i < BLKCG_MAX_POLS ; i++) {
...@@ -1168,10 +1165,9 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css) ...@@ -1168,10 +1165,9 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
continue; continue;
cpd = pol->cpd_alloc_fn(GFP_KERNEL); cpd = pol->cpd_alloc_fn(GFP_KERNEL);
if (!cpd) { if (!cpd)
ret = ERR_PTR(-ENOMEM);
goto free_pd_blkcg; goto free_pd_blkcg;
}
blkcg->cpd[i] = cpd; blkcg->cpd[i] = cpd;
cpd->blkcg = blkcg; cpd->blkcg = blkcg;
cpd->plid = i; cpd->plid = i;
...@@ -1200,7 +1196,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css) ...@@ -1200,7 +1196,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
kfree(blkcg); kfree(blkcg);
unlock: unlock:
mutex_unlock(&blkcg_pol_mutex); mutex_unlock(&blkcg_pol_mutex);
return ret; return ERR_PTR(-ENOMEM);
} }
static int blkcg_css_online(struct cgroup_subsys_state *css) static int blkcg_css_online(struct cgroup_subsys_state *css)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment