[dm-devel] [PATCH 1/3 v4] crypto: introduce the flag CRYPTO_ALG_ALLOCATES_MEMORY

Mikulas Patocka mpatocka at redhat.com
Tue Jun 30 18:14:25 UTC 2020



On Tue, 30 Jun 2020, Eric Biggers wrote:

> On Tue, Jun 30, 2020 at 01:01:16PM -0400, Mikulas Patocka wrote:
> > > diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
> > > index 7240e8bbdebb..643f7f1cc91c 100644
> > > --- a/crypto/pcrypt.c
> > > +++ b/crypto/pcrypt.c
> > > @@ -232,12 +232,15 @@ static int pcrypt_create_aead(struct crypto_template *tmpl, struct rtattr **tb,
> > >  	struct crypto_attr_type *algt;
> > >  	struct aead_instance *inst;
> > >  	struct aead_alg *alg;
> > > +	u32 mask;
> > >  	int err;
> > >  
> > >  	algt = crypto_get_attr_type(tb);
> > >  	if (IS_ERR(algt))
> > >  		return PTR_ERR(algt);
> > >  
> > > +	mask = crypto_alg_inherited_mask(algt->type, algt->mask);
> > > +
> > >  	inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
> > >  	if (!inst)
> > >  		return -ENOMEM;
> > > @@ -254,7 +257,7 @@ static int pcrypt_create_aead(struct crypto_template *tmpl, struct rtattr **tb,
> > >  		goto err_free_inst;
> > >  
> > >  	err = crypto_grab_aead(&ctx->spawn, aead_crypto_instance(inst),
> > > -			       crypto_attr_alg_name(tb[1]), 0, 0);
> > > +			       crypto_attr_alg_name(tb[1]), 0, mask);
> > >  	if (err)
> > >  		goto err_free_inst;
> > >  
> > 
> > I added "mask" there - but there is still a "mask" argument that is 
> > unused - is it a bug to have two "mask" variables?
> 
> Right, I didn't see that algt->type and algt->mask are already being passed to 
> pcrypt_create_aead().  It's redundant because pcrypt_create_aead() has access to
> those via crypto_get_attr_type() anyway.
> 
> How about just removing those two arguments for now?
> 
> - Eric

Yes.

Mikulas




More information about the dm-devel mailing list