blkcg: add sanity check for blkcg policy operations
Subsystems (2)
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.
Signed-off-by weiping zhang <[email protected]>
--- block/blk-cgroup.c | 7 +++++++ 1 file changed, 7 insertions(+)
block/blk-cgroup.c +7 -0
@@ -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
Looks good,
Reviewed-by Johannes Thumshirn <[email protected]>
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