diff mbox series

[-next] crypto: ccp - Use kmemdup in ccp_copy_and_save_keypart()

Message ID 20190330014316.174072-1-yuehaibing@huawei.com (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series [-next] crypto: ccp - Use kmemdup in ccp_copy_and_save_keypart() | expand

Commit Message

Yue Haibing March 30, 2019, 1:43 a.m. UTC
Use kmemdup rather than duplicating its implementation

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/crypto/ccp/ccp-crypto-rsa.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Gary R Hook April 1, 2019, 1:27 p.m. UTC | #1
On 3/29/19 8:43 PM, YueHaibing wrote:
> Use kmemdup rather than duplicating its implementation
> 
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Acked-by: Gary R Hook <gary.hook@amd.com>

> ---
>   drivers/crypto/ccp/ccp-crypto-rsa.c | 3 +--
>   1 file changed, 1 insertion(+), 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;
>   }
> 
> 
>
Herbert Xu April 8, 2019, 6:40 a.m. UTC | #2
On Sat, Mar 30, 2019 at 01:43:16AM +0000, YueHaibing wrote:
> Use kmemdup rather than duplicating its implementation
> 
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  drivers/crypto/ccp/ccp-crypto-rsa.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Patch applied.  Thanks.
diff mbox series

Patch

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;
 }