Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c18c9e9 authored by weiping zhang's avatar weiping zhang Committed by Jens Axboe
Browse files

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: default avatarweiping zhang <zhangweiping@didichuxing.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 231b3db1
Loading
Loading
Loading
Loading
+5 −3
Original line number Original line Diff line number Diff line
@@ -1067,7 +1067,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
		blkcg = kzalloc(sizeof(*blkcg), GFP_KERNEL);
		blkcg = kzalloc(sizeof(*blkcg), GFP_KERNEL);
		if (!blkcg) {
		if (!blkcg) {
			ret = ERR_PTR(-ENOMEM);
			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--)
	for (i--; i >= 0; i--)
		if (blkcg->cpd[i])
		if (blkcg->cpd[i])
			blkcg_policy[i]->cpd_free_fn(blkcg->cpd[i]);
			blkcg_policy[i]->cpd_free_fn(blkcg->cpd[i]);
free_blkcg:

	if (blkcg != &blkcg_root)
		kfree(blkcg);
		kfree(blkcg);
unlock:
	mutex_unlock(&blkcg_pol_mutex);
	mutex_unlock(&blkcg_pol_mutex);
	return ret;
	return ret;
}
}