diff mbox series

[-next] crypto: seqiv - Use kmemdup in seqiv_aead_encrypt()

Message ID 1548057420-140382-1-git-send-email-yuehaibing@huawei.com (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series [-next] crypto: seqiv - Use kmemdup in seqiv_aead_encrypt() | expand

Commit Message

Yue Haibing Jan. 21, 2019, 7:57 a.m. UTC
Use kmemdup rather than duplicating its implementation

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 crypto/seqiv.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Herbert Xu Feb. 1, 2019, 6:48 a.m. UTC | #1
On Mon, Jan 21, 2019 at 07:57:00AM +0000, YueHaibing wrote:
> Use kmemdup rather than duplicating its implementation
> 
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Patch applied.  Thanks.
diff mbox series

Patch

diff --git a/crypto/seqiv.c b/crypto/seqiv.c
index 64a412b..ed1b0e9 100644
--- a/crypto/seqiv.c
+++ b/crypto/seqiv.c
@@ -89,13 +89,12 @@  static int seqiv_aead_encrypt(struct aead_request *req)
 
 	if (unlikely(!IS_ALIGNED((unsigned long)info,
 				 crypto_aead_alignmask(geniv) + 1))) {
-		info = kmalloc(ivsize, req->base.flags &
-				       CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL:
-								  GFP_ATOMIC);
+		info = kmemdup(req->iv, ivsize, req->base.flags &
+			       CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL :
+			       GFP_ATOMIC);
 		if (!info)
 			return -ENOMEM;
 
-		memcpy(info, req->iv, ivsize);
 		compl = seqiv_aead_encrypt_complete;
 		data = req;
 	}