blk-cgroup: fix freeing NULL blkg in blkg_create
Subsystems (2)
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")
Reported-by Yi Zhang <[email protected]>
Signed-off-by Christoph Hellwig <[email protected]>
--- block/blk-cgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
block/blk-cgroup.c +2 -1
@@ -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
Quoted 7 lines · Christoph Hellwig
new_blkgcan 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")Reported-by Yi Zhang <[email protected]>Signed-off-by Christoph Hellwig <[email protected]>---
This should fix the issue reported by Yi, it will be great to get tested by though.
Reviewed-by Chaitanya Kulkarni <[email protected]>
-ck
Quoted 4 lines · Christoph Hellwig
new_blkgcan 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