[PATCH] crypto: api - don't use ksize()

From: Pekka Enberg
Date: Tue Feb 10 2009 - 09:01:27 EST


The ksize() function is not exported to modules because it has non-standard
behavour across different slab allocators. While it is technically ok for this
particular call-site, we do not want the use of the API to spread so fix it up
by adding a ->size member to struct crypto_tfm and use that instead.

Cc: Geert Uytterhoeven <Geert.Uytterhoeven@xxxxxxxxxxx>
Cc: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxxxxxx>
---
crypto/api.c | 6 +++---
include/linux/crypto.h | 2 ++
2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/crypto/api.c b/crypto/api.c
index efe77df..3526cc0 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -374,6 +374,7 @@ struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,
goto out_err;

tfm->__crt_alg = alg;
+ tfm->size = tfm_size;

err = crypto_init_ops(tfm, type, mask);
if (err)
@@ -471,6 +472,7 @@ struct crypto_tfm *crypto_create_tfm(struct crypto_alg *alg,

tfm = (struct crypto_tfm *)(mem + tfmsize);
tfm->__crt_alg = alg;
+ tfm->size = total;

err = frontend->init_tfm(tfm, frontend);
if (err)
@@ -569,19 +571,17 @@ EXPORT_SYMBOL_GPL(crypto_alloc_tfm);
void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm)
{
struct crypto_alg *alg;
- int size;

if (unlikely(!mem))
return;

alg = tfm->__crt_alg;
- size = ksize(mem);

if (!tfm->exit && alg->cra_exit)
alg->cra_exit(tfm);
crypto_exit_ops(tfm);
crypto_mod_put(alg);
- memset(mem, 0, size);
+ memset(mem, 0, tfm->size);
kfree(mem);
}
EXPORT_SYMBOL_GPL(crypto_destroy_tfm);
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index 1f2e902..4fd363a 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -487,6 +487,8 @@ struct crypto_tfm {

struct crypto_alg *__crt_alg;

+ size_t size;
+
void *__crt_ctx[] CRYPTO_MINALIGN_ATTR;
};

--
1.5.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/