Skip to contentSkip to conversation

blk-cgroup: fix freeing NULL blkg in blkg_create

PATCH Applied Christoph Hellwig 3 participants 3 messages Feb 6, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blk-cgroup: fix freeing NULL blkg in blkg_create

new_blkg can be NULL if the caller didn't pass in a pre-allocated blkg. Don't try to free it in that case.

Fixes 27b642b07a4a ("blk-cgroup: simplify blkg freeing from initialization failure paths")
---
 block/blk-cgroup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
block/blk-cgroup.c +2 -1
index 8faeca6022bea0..c46778d1f3c27d 100644
@@ -383,7 +383,8 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg, struct gendisk *disk,
 err_put_css:
 	css_put(&blkcg->css);
 err_free_blkg:
-	blkg_free(new_blkg);
+	if (new_blkg)
+		blkg_free(new_blkg);
 	return ERR_PTR(ret);
 }
 
Signature · 1 line
2.39.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Christoph Hellwig

new_blkg can be NULL if the caller didn't pass in a pre-allocated blkg. Don't try to free it in that case.

Fixes 27b642b07a4a ("blk-cgroup: simplify blkg freeing from initialization failure paths")

---

This should fix the issue reported by Yi, it will be great to get tested by though.

-ck

maintainer Applied
#2 lore raw
In reply to Christoph Hellwig
Quoted 4 lines · Christoph Hellwig

new_blkg can be NULL if the caller didn't pass in a pre-allocated blkg. Don't try to free it in that case.

Applied, thanks!

[1/1] blk-cgroup: fix freeing NULL blkg in blkg_create

      commit: 28e538a3093833cbac3e28dd511a8b74629d737a

Best regards,

Signature · 1 line
Jens Axboe