Hi Ard, On Fri, Jul 21, 2017 at 04:42:38PM +0100, Ard Biesheuvel wrote: > +static int crypto_scomp_init_tfm(struct crypto_tfm *tfm) > +{ > + int ret; > + > + mutex_lock(&scomp_lock); > + ret = crypto_scomp_alloc_all_scratches(); > + mutex_unlock(&scomp_lock); > + > + return ret; > +} If you allocate the scratch buffers at init_tfm, don't you end up with a situation where if you allocate two tfms of the same algo then you get twice the number of scratches? If that is the case, we should implement a reference count mechanism. Am I missing something? Regards, -- Giovanni