crypto: seqiv - Use kmemdup in seqiv_aead_encrypt()
authorYueHaibing <yuehaibing@huawei.com>
Mon, 21 Jan 2019 07:57:00 +0000 (07:57 +0000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 1 Feb 2019 06:42:03 +0000 (14:42 +0800)
Use kmemdup rather than duplicating its implementation

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/seqiv.c

index 64a412b..ed1b0e9 100644 (file)
@@ -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;
        }