Re: [PATCH v2] blkcg: add sanity check for blkcg policy operations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 11, 2017 at 10:51:32AM -0600, Jens Axboe wrote:
> On 10/11/2017 03:46 AM, weiping zhang wrote:
> > 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@xxxxxxxxxxxxxxx>
> > ---
> >  block/blk-cgroup.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> > index e7ec676..67b01c5 100644
> > --- a/block/blk-cgroup.c
> > +++ b/block/blk-cgroup.c
> > @@ -1419,6 +1419,16 @@ 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) ||
> > +		(!pol->cpd_alloc_fn && pol->cpd_free_fn))
> > +		goto err_unlock;
> 
> This might be cleaner (and more readable) as:
> 
>         if (!pol->cpd_alloc_fn ^ !pol->cpd_free_fn)
>                 goto err_unlock;
> 
> Ditto for the pd part.
> 
Really nice, I'll send v3.

Thanks



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux