crypto: ccp - Use kmemdup in ccp_copy_and_save_keypart()
authorYueHaibing <yuehaibing@huawei.com>
Sat, 30 Mar 2019 01:43:16 +0000 (01:43 +0000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 8 Apr 2019 06:36:16 +0000 (14:36 +0800)
Use kmemdup rather than duplicating its implementation

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Gary R Hook <gary.hook@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/ccp/ccp-crypto-rsa.c

index 0b8aab009e7b170393b21b5a1f220bc5d74adaff..841acdffbc3ce1583e07f528529d5f9cbd46ebf4 100644 (file)
@@ -37,10 +37,9 @@ static inline int ccp_copy_and_save_keypart(u8 **kpbuf, unsigned int *kplen,
                if (buf[nskip])
                        break;
        *kplen = sz - nskip;
-       *kpbuf = kzalloc(*kplen, GFP_KERNEL);
+       *kpbuf = kmemdup(buf + nskip, *kplen, GFP_KERNEL);
        if (!*kpbuf)
                return -ENOMEM;
-       memcpy(*kpbuf, buf + nskip, *kplen);
 
        return 0;
 }