if alloc memory fail, all cpds which were allocated before should be cleaned up.

Signed-off-by: weiping zhang <zhangweip...@didichuxing.com>
---
 block/blk-cgroup.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 0480892..7e21c4b 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -1336,6 +1336,17 @@ int blkcg_activate_policy(struct request_queue *q,
 
        spin_unlock_irq(q->queue_lock);
 out_bypass_end:
+       if (ret) {
+               spin_lock_irq(q->queue_lock);
+               list_for_each_entry(blkg, &q->blkg_list, q_node) {
+                       if (blkg->pd[pol->plid]) {
+                               if (pol->pd_free_fn)
+                                       pol->pd_free_fn(blkg->pd[pol->plid]);
+                               blkg->pd[pol->plid] = NULL;
+                       }
+               }
+               spin_unlock_irq(q->queue_lock);
+       }
        if (q->mq_ops)
                blk_mq_unfreeze_queue(q);
        else
-- 
2.9.4

Reply via email to