if (blkcg_policy_enabled(q, pol))
                return 0;
 
+       /*
+        * Policy is allowed to be registered without pd_alloc_fn/pd_free_fn,
+        * for example, ioprio. Such policy will work on blkcg level, not disk
+        * level, and don't need to be activated.
+        */
+       if (WARN_ON_ONCE(!pol->pd_alloc_fn || !pol->pd_free_fn))
+               return -EINVAL;
+
        if (queue_is_mq(q))
                blk_mq_freeze_queue(q);
 retry:
                goto err_unlock;
        }
 
-       /* Make sure cpd/pd_alloc_fn and cpd/pd_free_fn in pairs */
+       /*
+        * Make sure cpd/pd_alloc_fn and cpd/pd_free_fn in pairs, and policy
+        * without pd_alloc_fn/pd_free_fn can't be activated.
+        */
        if ((!pol->cpd_alloc_fn ^ !pol->cpd_free_fn) ||
-               (!pol->pd_alloc_fn ^ !pol->pd_free_fn))
+           (!pol->pd_alloc_fn ^ !pol->pd_free_fn))
                goto err_unlock;
 
        /* register @pol */