All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blkcg: avoid free blkcg_root when failed to alloc blkcg policy
@ 2017-08-25 15:49 weiping zhang
  2017-08-25 19:50 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: weiping zhang @ 2017-08-25 15:49 UTC (permalink / raw)
  To: axboe; +Cc: linux-block

this patch fix two errors, firstly avoid kfree blk_root, secondly not
free(blkcg) ,if blkcg alloc fail(blkcg == NULL), just unlock that mutex;

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
---
 block/blk-cgroup.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 0480892..d3f56ba 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -1067,7 +1067,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
 		blkcg = kzalloc(sizeof(*blkcg), GFP_KERNEL);
 		if (!blkcg) {
 			ret = ERR_PTR(-ENOMEM);
-			goto free_blkcg;
+			goto unlock;
 		}
 	}
 
@@ -1111,8 +1111,10 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
 	for (i--; i >= 0; i--)
 		if (blkcg->cpd[i])
 			blkcg_policy[i]->cpd_free_fn(blkcg->cpd[i]);
-free_blkcg:
-	kfree(blkcg);
+
+	if (blkcg != &blkcg_root)
+		kfree(blkcg);
+unlock:
 	mutex_unlock(&blkcg_pol_mutex);
 	return ret;
 }
-- 
2.9.4

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

* Re: [PATCH] blkcg: avoid free blkcg_root when failed to alloc blkcg policy
  2017-08-25 15:49 [PATCH] blkcg: avoid free blkcg_root when failed to alloc blkcg policy weiping zhang
@ 2017-08-25 19:50 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2017-08-25 19:50 UTC (permalink / raw)
  To: weiping zhang; +Cc: linux-block

On 08/25/2017 09:49 AM, weiping zhang wrote:
> this patch fix two errors, firstly avoid kfree blk_root, secondly not
> free(blkcg) ,if blkcg alloc fail(blkcg == NULL), just unlock that mutex;

Looks good, applied.

-- 
Jens Axboe

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

end of thread, other threads:[~2017-08-25 19:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-25 15:49 [PATCH] blkcg: avoid free blkcg_root when failed to alloc blkcg policy weiping zhang
2017-08-25 19:50 ` Jens Axboe

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.