* Patch(2.5.50): Simplify crypto memory allocation
@ 2002-12-08 9:27 Adam J. Richter
2002-12-08 10:55 ` James Morris
0 siblings, 1 reply; 3+ messages in thread
From: Adam J. Richter @ 2002-12-08 9:27 UTC (permalink / raw)
To: jmorris, davem, astor; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 835 bytes --]
The following patch deletes the unused
crypto_tfm.crt_work_block field and combines the remaining
two kmallocs done by crypto_alloc_tfm into one, a net
deletion of 25 lines.
I've only verified that the kernel and the crpypto modules
still build. I don't currently use this code, although I'm
considering making a version of loop.c which would, which is why I
noticed this.
Anyhow, if this patch turns out to work and looks OK, then
please integrate, queue it for Linus, etc., or let me know if you
would prefer that you or I follow some other course of action.
--
Adam J. Richter __ ______________ 575 Oroville Road
adam@yggdrasil.com \ / Milpitas, California 95035
+1 408 309-6081 | g g d r a s i l United States of America
"Free Software For The Rest Of Us."
[-- Attachment #2: crypt.diff --]
[-- Type: text/plain, Size: 1747 bytes --]
--- linux-2.5.50/include/linux/crypto.h 2002-11-27 14:35:54.000000000 -0800
+++ linux/include/linux/crypto.h 2002-12-08 01:06:24.000000000 -0800
@@ -161,7 +161,6 @@
struct crypto_tfm {
void *crt_ctx;
- void *crt_work_block;
u32 crt_flags;
union {
--- linux-2.5.50/crypto/api.c 2002-11-27 14:36:21.000000000 -0800
+++ linux/crypto/api.c 2002-12-08 01:06:35.000000000 -0800
@@ -124,44 +124,26 @@
if (alg == NULL)
goto out;
- tfm = kmalloc(sizeof(*tfm), GFP_KERNEL);
+ tfm = kmalloc(sizeof(*tfm) + alg->cra_ctxsize, GFP_KERNEL);
if (tfm == NULL)
goto out_put;
memset(tfm, 0, sizeof(*tfm));
- if (alg->cra_ctxsize) {
- tfm->crt_ctx = kmalloc(alg->cra_ctxsize, GFP_KERNEL);
- if (tfm->crt_ctx == NULL)
- goto out_free_tfm;
- }
+ tfm->crt_ctx = (void*) &tfm[1];
tfm->__crt_alg = alg;
- if (alg->cra_blocksize) {
- tfm->crt_work_block = kmalloc(alg->cra_blocksize + 1,
- GFP_KERNEL);
- if (tfm->crt_work_block == NULL)
- goto out_free_ctx;
- }
-
if (crypto_init_flags(tfm, flags))
- goto out_free_work_block;
+ goto out_free_tfm;
if (crypto_init_ops(tfm)) {
crypto_exit_ops(tfm);
- goto out_free_ctx;
+ goto out_free_tfm;
}
goto out;
-out_free_work_block:
- if (tfm->__crt_alg->cra_blocksize)
- kfree(tfm->crt_work_block);
-
-out_free_ctx:
- if (tfm->__crt_alg->cra_ctxsize)
- kfree(tfm->crt_ctx);
out_free_tfm:
kfree(tfm);
tfm = NULL;
@@ -173,12 +155,6 @@
void crypto_free_tfm(struct crypto_tfm *tfm)
{
- if (tfm->__crt_alg->cra_ctxsize)
- kfree(tfm->crt_ctx);
-
- if (tfm->__crt_alg->cra_blocksize)
- kfree(tfm->crt_work_block);
-
if (crypto_tfm_alg_type(tfm) == CRYPTO_ALG_TYPE_CIPHER)
if (tfm->crt_cipher.cit_iv)
kfree(tfm->crt_cipher.cit_iv);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Patch(2.5.50): Simplify crypto memory allocation
2002-12-08 9:27 Patch(2.5.50): Simplify crypto memory allocation Adam J. Richter
@ 2002-12-08 10:55 ` James Morris
2002-12-08 22:31 ` David S. Miller
0 siblings, 1 reply; 3+ messages in thread
From: James Morris @ 2002-12-08 10:55 UTC (permalink / raw)
To: Adam J. Richter; +Cc: David S. Miller, linux-kernel
On Sun, 8 Dec 2002, Adam J. Richter wrote:
> The following patch deletes the unused
> crypto_tfm.crt_work_block field and combines the remaining
> two kmallocs done by crypto_alloc_tfm into one, a net
> deletion of 25 lines.
>
> I've only verified that the kernel and the crpypto modules
> still build. I don't currently use this code, although I'm
> considering making a version of loop.c which would, which is why I
> noticed this.
>
> Anyhow, if this patch turns out to work and looks OK, then
> please integrate, queue it for Linus, etc., or let me know if you
> would prefer that you or I follow some other course of action.
>
Looks good and tests ok. Thanks.
(The work_block field and associated management code should have
disappeared long ago, not sure why it was still there).
- James
--
James Morris
<jmorris@intercode.com.au>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Patch(2.5.50): Simplify crypto memory allocation
2002-12-08 10:55 ` James Morris
@ 2002-12-08 22:31 ` David S. Miller
0 siblings, 0 replies; 3+ messages in thread
From: David S. Miller @ 2002-12-08 22:31 UTC (permalink / raw)
To: jmorris; +Cc: adam, linux-kernel
From: James Morris <jmorris@intercode.com.au>
Date: Sun, 8 Dec 2002 21:55:15 +1100 (EST)
On Sun, 8 Dec 2002, Adam J. Richter wrote:
> Anyhow, if this patch turns out to work and looks OK, then
> please integrate, queue it for Linus, etc., or let me know if you
> would prefer that you or I follow some other course of action.
Looks good and tests ok. Thanks.
I'll apply this, thanks Adam.
(The work_block field and associated management code should have
disappeared long ago, not sure why it was still there).
We just didn't do this part when the conversion was made :-)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-12-08 22:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-08 9:27 Patch(2.5.50): Simplify crypto memory allocation Adam J. Richter
2002-12-08 10:55 ` James Morris
2002-12-08 22:31 ` David S. Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome