Skip to content

Commit b5a9adc

Browse files
Waiman-Longaxboe
authored andcommitted
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: Waiman Long <longman@redhat.com> Reviewed-by: Ming Lei <ming.lei@redhat.com> Acked-by: Tejun Heo <tj@kernel.org> Link: https://lore.kernel.org/r/20221105005902.407297-2-longman@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 077a403 commit b5a9adc

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

block/blk-cgroup.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,6 @@ static struct cgroup_subsys_state *
11391139
blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
11401140
{
11411141
struct blkcg *blkcg;
1142-
struct cgroup_subsys_state *ret;
11431142
int i;
11441143

11451144
mutex_lock(&blkcg_pol_mutex);
@@ -1148,10 +1147,8 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
11481147
blkcg = &blkcg_root;
11491148
} else {
11501149
blkcg = kzalloc(sizeof(*blkcg), GFP_KERNEL);
1151-
if (!blkcg) {
1152-
ret = ERR_PTR(-ENOMEM);
1150+
if (!blkcg)
11531151
goto unlock;
1154-
}
11551152
}
11561153

11571154
for (i = 0; i < BLKCG_MAX_POLS ; i++) {
@@ -1168,10 +1165,9 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
11681165
continue;
11691166

11701167
cpd = pol->cpd_alloc_fn(GFP_KERNEL);
1171-
if (!cpd) {
1172-
ret = ERR_PTR(-ENOMEM);
1168+
if (!cpd)
11731169
goto free_pd_blkcg;
1174-
}
1170+
11751171
blkcg->cpd[i] = cpd;
11761172
cpd->blkcg = blkcg;
11771173
cpd->plid = i;
@@ -1200,7 +1196,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
12001196
kfree(blkcg);
12011197
unlock:
12021198
mutex_unlock(&blkcg_pol_mutex);
1203-
return ret;
1199+
return ERR_PTR(-ENOMEM);
12041200
}
12051201

12061202
static int blkcg_css_online(struct cgroup_subsys_state *css)

0 commit comments

Comments
 (0)