From: weiping zhang <zhangweiping@didichuxing.com>
To: <axboe@kernel.dk>
Cc: <linux-block@vger.kernel.org>
Subject: [PATCH] blkcg: check pol->cpd_free_fn before free cpd
Date: Wed, 30 Aug 2017 00:08:17 +0800 [thread overview]
Message-ID: <20170829160811.GA1324@localhost.didichuxing.com> (raw)
check pol->cpd_free_fn() instead of pol->cpd_alloc_fn() when free cpd.
Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
---
block/blk-cgroup.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 0480892..adcbc3e 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -1044,7 +1044,7 @@ static void blkcg_css_free(struct cgroup_subsys_state *css)
list_del(&blkcg->all_blkcgs_node);
for (i = 0; i < BLKCG_MAX_POLS; i++)
- if (blkcg->cpd[i])
+ if (blkcg->cpd[i] && blkcg_policy[i]->cpd_free_fn)
blkcg_policy[i]->cpd_free_fn(blkcg->cpd[i]);
mutex_unlock(&blkcg_pol_mutex);
@@ -1109,7 +1109,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
free_pd_blkcg:
for (i--; i >= 0; i--)
- if (blkcg->cpd[i])
+ if (blkcg->cpd[i] && blkcg_policy[i]->cpd_free_fn)
blkcg_policy[i]->cpd_free_fn(blkcg->cpd[i]);
free_blkcg:
kfree(blkcg);
@@ -1450,7 +1450,7 @@ int blkcg_policy_register(struct blkcg_policy *pol)
return 0;
err_free_cpds:
- if (pol->cpd_alloc_fn) {
+ if (pol->cpd_free_fn) {
list_for_each_entry(blkcg, &all_blkcgs, all_blkcgs_node) {
if (blkcg->cpd[pol->plid]) {
pol->cpd_free_fn(blkcg->cpd[pol->plid]);
@@ -1490,7 +1490,7 @@ void blkcg_policy_unregister(struct blkcg_policy *pol)
/* remove cpds and unregister */
mutex_lock(&blkcg_pol_mutex);
- if (pol->cpd_alloc_fn) {
+ if (pol->cpd_free_fn) {
list_for_each_entry(blkcg, &all_blkcgs, all_blkcgs_node) {
if (blkcg->cpd[pol->plid]) {
pol->cpd_free_fn(blkcg->cpd[pol->plid]);
--
2.9.4
next reply other threads:[~2017-08-29 16:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-29 16:08 weiping zhang [this message]
-- strict thread matches above, loose matches on Subject: below --
2017-10-10 14:53 [PATCH] blkcg: check pol->cpd_free_fn before free cpd weiping zhang
2017-10-10 14:59 ` Johannes Thumshirn
2017-10-10 15:04 ` Jens Axboe
2017-10-10 15:44 ` weiping zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170829160811.GA1324@localhost.didichuxing.com \
--to=zhangweiping@didichuxing.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.