Skip to contentSkip to conversation

blkcg: add sanity check for blkcg policy operations

PATCH Superseded weiping zhang 2 participants 2 messages Oct 12, 2017

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 blkcg: add sanity check for blkcg policy operations

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

---
 block/blk-cgroup.c | 7 +++++++
 1 file changed, 7 insertions(+)
block/blk-cgroup.c +7 -0
index e7ec676..6c5f5f3 100644
@@ -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;
Signature · 1 line
2.9.4
Reviewed-by on v3 1/1
#1 lore raw

Looks good,

Signature · 6 lines
Johannes Thumshirn                                          Storage
[email protected]                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg
GF: Felix Imend�rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N�rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850