]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
crypto: caam: - Use kmemdup() function
authorFabio Estevam <fabio.estevam@nxp.com>
Mon, 16 Apr 2018 16:05:01 +0000 (13:05 -0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 20 Apr 2018 16:59:04 +0000 (00:59 +0800)
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: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/caam/caampkc.c

index 979072b25eaa61f7517aea19174a40c4b64613d2..6f990139f32471d7168161aaab1e39b3d2b27eb8 100644 (file)
@@ -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)
 {
-       u8 *val;
 
        caam_rsa_drop_leading_zeros(&buf, nbytes);
        if (!*nbytes)
                return NULL;
 
-       val = kzalloc(*nbytes, GFP_DMA | GFP_KERNEL);
-       if (!val)
-               return NULL;
-
-       memcpy(val, buf, *nbytes);
-
-       return val;
+       return kmemdup(buf, *nbytes, GFP_DMA | GFP_KERNEL);
 }
 
 static int caam_rsa_check_key_length(unsigned int len)