2009-07-22 09:48:48

by Steffen Klassert

[permalink] [raw]
Subject: [PATCH] crypto: ahash - Use GFP_KERNEL on allocation if the request can sleep

ahash_op_unaligned() and ahash_def_finup() allocate memory atomically,
regardless whether the request can sleep or not. This patch changes
this to use GFP_KERNEL if the request can sleep.

Signed-off-by: Steffen Klassert <[email protected]>
---
crypto/ahash.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/crypto/ahash.c b/crypto/ahash.c
index 28a33d0..33a4ff4 100644
--- a/crypto/ahash.c
+++ b/crypto/ahash.c
@@ -223,7 +223,7 @@ static int ahash_op_unaligned(struct ahash_request *req,

priv = kmalloc(sizeof(*priv) + ahash_align_buffer_size(ds, alignmask),
(req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
- GFP_ATOMIC : GFP_ATOMIC);
+ GFP_KERNEL : GFP_ATOMIC);
if (!priv)
return -ENOMEM;

@@ -333,7 +333,7 @@ static int ahash_def_finup(struct ahash_request *req)

priv = kmalloc(sizeof(*priv) + ahash_align_buffer_size(ds, alignmask),
(req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
- GFP_ATOMIC : GFP_ATOMIC);
+ GFP_KERNEL : GFP_ATOMIC);
if (!priv)
return -ENOMEM;

--
1.5.4.2



2009-07-22 12:23:08

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: ahash - Use GFP_KERNEL on allocation if the request can sleep

On Wed, Jul 22, 2009 at 11:51:23AM +0200, Steffen Klassert wrote:
> ahash_op_unaligned() and ahash_def_finup() allocate memory atomically,
> regardless whether the request can sleep or not. This patch changes
> this to use GFP_KERNEL if the request can sleep.
>
> Signed-off-by: Steffen Klassert <[email protected]>

Doh, I don't know what I was thinking when I wrote that :)

Thanks for catching this, I'll apply the patch.
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt