Re: [PATCH] crypto: caam: - Use kmemdup() function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/16/2018 5:08 PM, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@xxxxxxx>
> 
> Use kmemdup() rather than duplicating its implementation.
> 
> Detected with Coccinelle script.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@xxxxxxx>
> ---
>  drivers/crypto/caam/caampkc.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/crypto/caam/caampkc.c b/drivers/crypto/caam/caampkc.c
> index 979072b..c3518ce 100644
> --- a/drivers/crypto/caam/caampkc.c
> +++ b/drivers/crypto/caam/caampkc.c
> @@ -789,12 +789,10 @@ static inline u8 *caam_read_raw_data(const u8 *buf, size_t *nbytes)
>  	if (!*nbytes)
>  		return NULL;
>  
> -	val = kzalloc(*nbytes, GFP_DMA | GFP_KERNEL);
> +	val = kmemdup(buf, *nbytes, GFP_DMA | GFP_KERNEL);
>  	if (!val)
>  		return NULL;
>  
> -	memcpy(val, buf, *nbytes);
> -
>  	return val;
>  }
Could be further simplified:
	return kmemdup(...);

Horia




[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux