Linux cgroups development
 help / color / mirror / Atom feed
* [PATCH] blk-cgroup: fix blkg->online set on radix_tree_insert failure
@ 2026-05-06 13:11 Tao Cui
  2026-05-07  4:42 ` [PATCH v2] blk-cgroup: fix leaks and online flag " Tao Cui
  2026-05-07  6:12 ` [PATCH v3] " Tao Cui
  0 siblings, 2 replies; 4+ messages in thread
From: Tao Cui @ 2026-05-06 13:11 UTC (permalink / raw)
  To: tj, josef, axboe, cgroups; +Cc: Tao Cui

In blkg_create(), blkg->online was set to true unconditionally outside
the radix_tree_insert success check. When the insertion fails, the blkg
is not in the radix tree nor the hash/list, yet it is incorrectly marked
online. This state inconsistency could cause future code paths that
depend on blkg->online to behave incorrectly.

Move blkg->online = true inside the if (likely(!ret)) block so that it
is only set when the blkg is fully initialized and inserted.

Signed-off-by: Tao Cui <cuitao@kylinos.cn>
---
 block/blk-cgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 554c87bb4a86..539301f4f645 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -431,8 +431,8 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg, struct gendisk *disk,
 				blkg->pd[i]->online = true;
 			}
 		}
+		blkg->online = true;
 	}
-	blkg->online = true;
 	spin_unlock(&blkcg->lock);
 
 	if (!ret)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-05-08  0:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-06 13:11 [PATCH] blk-cgroup: fix blkg->online set on radix_tree_insert failure Tao Cui
2026-05-07  4:42 ` [PATCH v2] blk-cgroup: fix leaks and online flag " Tao Cui
2026-05-07  6:12 ` [PATCH v3] " Tao Cui
2026-05-08  0:27   ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox