Commit b930f3a2 authored by Fabio Estevam's avatar Fabio Estevam Committed by Herbert Xu

crypto: caam: - Use kmemdup() function

Use kmemdup() rather than duplicating its implementation.

By usign kmemdup() we can also get rid of the 'val' variable.

Detected with Coccinelle script.
Signed-off-by: default avatarFabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: default avatarHoria Geantă <horia.geanta@nxp.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 8a2a0dd3
...@@ -783,19 +783,12 @@ static u8 *caam_read_rsa_crt(const u8 *ptr, size_t nbytes, size_t dstlen) ...@@ -783,19 +783,12 @@ static u8 *caam_read_rsa_crt(const u8 *ptr, size_t nbytes, size_t dstlen)
*/ */
static inline u8 *caam_read_raw_data(const u8 *buf, size_t *nbytes) static inline u8 *caam_read_raw_data(const u8 *buf, size_t *nbytes)
{ {
u8 *val;
caam_rsa_drop_leading_zeros(&buf, nbytes); caam_rsa_drop_leading_zeros(&buf, nbytes);
if (!*nbytes) if (!*nbytes)
return NULL; return NULL;
val = kzalloc(*nbytes, GFP_DMA | GFP_KERNEL); return kmemdup(buf, *nbytes, GFP_DMA | GFP_KERNEL);
if (!val)
return NULL;
memcpy(val, buf, *nbytes);
return val;
} }
static int caam_rsa_check_key_length(unsigned int len) static int caam_rsa_check_key_length(unsigned int len)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment