Linux block layer
 help / color / mirror / Atom feed
* [PATCH v3] blkcg: add sanity check for blkcg policy operations
@ 2017-10-12  6:47 weiping zhang
  2017-10-12  7:58 ` Johannes Thumshirn
  0 siblings, 1 reply; 2+ messages in thread
From: weiping zhang @ 2017-10-12  6:47 UTC (permalink / raw)
  To: axboe, jthumshirn; +Cc: linux-block

blkcg policy should keep cpd/pd's alloc_fn and free_fn in pairs,
otherwise policy would register fail.

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

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index e7ec676..6c5f5f3 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -1419,6 +1419,13 @@ int blkcg_policy_register(struct blkcg_policy *pol)
 	if (i >= BLKCG_MAX_POLS)
 		goto err_unlock;
 
+	/* Make sure cpd_alloc_fn and cpd_free_fn in pairs */
+	if (!pol->cpd_alloc_fn ^ !pol->cpd_free_fn)
+		goto err_unlock;
+
+	if (!pol->pd_alloc_fn ^ !pol->pd_free_fn)
+		goto err_unlock;
+
 	/* register @pol */
 	pol->plid = i;
 	blkcg_policy[pol->plid] = pol;
-- 
2.9.4

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

end of thread, other threads:[~2017-10-12  7:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-12  6:47 [PATCH v3] blkcg: add sanity check for blkcg policy operations weiping zhang
2017-10-12  7:58 ` Johannes Thumshirn

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