summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYueHaibing <yuehaibing@huawei.com>2019-03-30 01:43:16 +0000
committerHerbert Xu <herbert@gondor.apana.org.au>2019-04-08 14:36:16 +0800
commit8316da02e3e07b0da9b2d812a619b5513c7f59d2 (patch)
tree6455c38ab2fe6a2968ef12e51c71ea607fbab43f
parent61abc356bf310d346d2d469cb009f6d4334f34de (diff)
crypto: ccp - Use kmemdup in ccp_copy_and_save_keypart()
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>
-rw-r--r--drivers/crypto/ccp/ccp-crypto-rsa.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/crypto/ccp/ccp-crypto-rsa.c b/drivers/crypto/ccp/ccp-crypto-rsa.c
index 0b8aab009e7b..841acdffbc3c 100644
--- a/drivers/crypto/ccp/ccp-crypto-rsa.c
+++ b/drivers/crypto/ccp/ccp-crypto-rsa.c
@@ -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;
}