diff options
author | Fabio Estevam <fabio.estevam@nxp.com> | 2018-04-16 18:05:01 +0200 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2018-04-20 18:59:04 +0200 |
commit | b930f3a2292d29e53caac1c82d44b655d8d40b72 (patch) | |
tree | 2d0e6343fd2cf9dada2777c990683c36c6d3dcb9 | |
parent | crypto: caam - strip input zeros from RSA input buffer (diff) | |
download | linux-b930f3a2292d29e53caac1c82d44b655d8d40b72.tar.xz linux-b930f3a2292d29e53caac1c82d44b655d8d40b72.zip |
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: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | drivers/crypto/caam/caampkc.c | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/drivers/crypto/caam/caampkc.c b/drivers/crypto/caam/caampkc.c index 979072b25eaa..6f990139f324 100644 --- a/drivers/crypto/caam/caampkc.c +++ b/drivers/crypto/caam/caampkc.c @@ -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) |