A couple more comments: On Wed, Feb 15, 2023 at 05:25:09PM +0800, Herbert Xu wrote: > +static int crypto_aead_report_stat(struct sk_buff *skb, struct crypto_alg *alg) > + __maybe_unused; > +static int crypto_aead_report_stat(struct sk_buff *skb, struct crypto_alg *alg) This could be just: static int __maybe_unused crypto_aead_report_stat(struct sk_buff *skb, struct crypto_alg *alg) > +{ > + struct aead_alg *aead = container_of(alg, struct aead_alg, base); > + struct crypto_istat_aead *istat = aead_get_stat(aead); > + struct crypto_stat_aead raead; > + > + memset(&raead, 0, sizeof(raead)); > + > + strscpy(raead.type, "aead", sizeof(raead.type)); > + > + raead.stat_encrypt_cnt = atomic64_read(&istat->encrypt_cnt); > + raead.stat_encrypt_tlen = atomic64_read(&istat->encrypt_tlen); > + raead.stat_decrypt_cnt = atomic64_read(&istat->decrypt_cnt); > + raead.stat_decrypt_tlen = atomic64_read(&istat->decrypt_tlen); > + raead.stat_err_cnt = atomic64_read(&istat->err_cnt); > + > + return nla_put(skb, CRYPTOCFGA_STAT_AEAD, sizeof(raead), &raead); > +} But actually it might be better to keep #ifdef-ing this whole function out when !CONFIG_CRYPTO_STATS, since in that case it contains an unconditional null pointer dereference. Yes, it's not executed, but it might be confusing. > static int aead_prepare_alg(struct aead_alg *alg) > { > + struct crypto_istat_aead *istat = aead_get_stat(alg); > struct crypto_alg *base = &alg->base; > > if (max3(alg->maxauthsize, alg->ivsize, alg->chunksize) > > @@ -232,6 +292,9 @@ static int aead_prepare_alg(struct aead_alg *alg) > base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK; > base->cra_flags |= CRYPTO_ALG_TYPE_AEAD; > > + if (IS_ENABLED(CONFIG_CRYPTO_STATS)) > + memset(istat, 0, sizeof(*istat)); > + Above is another place that can just do 'if (istat)'. - Eric