From: Yahu Gao <gaoyahu19@gmail.com>
To: Tejun Heo <tj@kernel.org>, Jens Axboe <axboe@kernel.dk>
Cc: cgroups@vger.kernel.org, linux-block@vger.kernel.org,
Yahu Gao <yahugao@didiglobal.com>,
Kunhai Dai <daikunhai@didiglobal.com>
Subject: [PATCH] block,iocost: fix potential kernel NULL
Date: Fri, 13 May 2022 22:59:28 +0800 [thread overview]
Message-ID: <20220513145928.29766-2-gaoyahu19@gmail.com> (raw)
In-Reply-To: <20220513145928.29766-1-gaoyahu19@gmail.com>
From: Yahu Gao <yahugao@didiglobal.com>
Some inode pinned dying memory cgroup and its parent destroyed at first.
The parent's pd of iocost won't be allocated during function
blkcg_activate_policy.
Ignore the DYING CSS to avoid kernel NULL during iocost policy data init.
Signed-off-by: Yahu Gao <yahugao@didiglobal.com>
Signed-off-by: Kunhai Dai <daikunhai@didiglobal.com>
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index a91f8ae18b49..32472de2e61d 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -1418,6 +1418,9 @@ int blkcg_activate_policy(struct request_queue *q,
list_for_each_entry_reverse(blkg, &q->blkg_list, q_node) {
struct blkg_policy_data *pd;
+ if (blkg->blkcg->css.flags & CSS_DYING)
+ continue;
+
if (blkg->pd[pol->plid])
continue;
@@ -1459,8 +1462,11 @@ int blkcg_activate_policy(struct request_queue *q,
/* all allocated, init in the same order */
if (pol->pd_init_fn)
- list_for_each_entry_reverse(blkg, &q->blkg_list, q_node)
+ list_for_each_entry_reverse(blkg, &q->blkg_list, q_node) {
+ if (blkg->blkcg->css.flags & CSS_DYING)
+ continue;
pol->pd_init_fn(blkg->pd[pol->plid]);
+ }
__set_bit(pol->plid, q->blkcg_pols);
ret = 0;
--
2.30.1
next prev parent reply other threads:[~2022-05-13 15:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-13 14:59 [PATCH 0/1] block,iocost: fix potential kernel NULL Yahu Gao
2022-05-13 14:59 ` Yahu Gao [this message]
2022-05-13 16:28 ` [PATCH] " Tejun Heo
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=20220513145928.29766-2-gaoyahu19@gmail.com \
--to=gaoyahu19@gmail.com \
--cc=axboe@kernel.dk \
--cc=cgroups@vger.kernel.org \
--cc=daikunhai@didiglobal.com \
--cc=linux-block@vger.kernel.org \
--cc=tj@kernel.org \
--cc=yahugao@didiglobal.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox