Skip to content

Commit 4b0de36

Browse files
committed
blk-cgroup: Return -ENOMEM directly in blkcg_css_alloc() error path
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2077665 commit b5a9adc Author: Waiman Long <longman@redhat.com> Date: Fri, 4 Nov 2022 20:59:00 -0400 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> Signed-off-by: Waiman Long <longman@redhat.com>
1 parent e0f91a5 commit 4b0de36

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
@@ -1140,7 +1140,6 @@ static struct cgroup_subsys_state *
11401140
blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
11411141
{
11421142
struct blkcg *blkcg;
1143-
struct cgroup_subsys_state *ret;
11441143
int i;
11451144

11461145
mutex_lock(&blkcg_pol_mutex);
@@ -1149,10 +1148,8 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
11491148
blkcg = &blkcg_root;
11501149
} else {
11511150
blkcg = kzalloc(sizeof(*blkcg), GFP_KERNEL);
1152-
if (!blkcg) {
1153-
ret = ERR_PTR(-ENOMEM);
1151+
if (!blkcg)
11541152
goto unlock;
1155-
}
11561153
}
11571154

11581155
for (i = 0; i < BLKCG_MAX_POLS ; i++) {
@@ -1169,10 +1166,9 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
11691166
continue;
11701167

11711168
cpd = pol->cpd_alloc_fn(GFP_KERNEL);
1172-
if (!cpd) {
1173-
ret = ERR_PTR(-ENOMEM);
1169+
if (!cpd)
11741170
goto free_pd_blkcg;
1175-
}
1171+
11761172
blkcg->cpd[i] = cpd;
11771173
cpd->blkcg = blkcg;
11781174
cpd->plid = i;
@@ -1201,7 +1197,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
12011197
kfree(blkcg);
12021198
unlock:
12031199
mutex_unlock(&blkcg_pol_mutex);
1204-
return ret;
1200+
return ERR_PTR(-ENOMEM);
12051201
}
12061202

12071203
static int blkcg_css_online(struct cgroup_subsys_state *css)

0 commit comments

Comments
 (0)