Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: caam - Clear some memory in instantiate_rng

According to the comment at the end of the 'for' loop just a few lines
below, it looks needed to clear 'desc'.

So it should also be cleared for the first iteration.

Move the memset() to the beginning of the loop to be safe.

Fixes: 281922a1d4f5 ("crypto: caam - add support for SEC v5.x RNG4")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Gaurav Jain <gaurav.jain@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Christophe JAILLET and committed by
Herbert Xu
9c19fb86 9117e682

+4 -2
+4 -2
drivers/crypto/caam/ctrl.c
··· 284 284 const u32 rdsta_if = RDSTA_IF0 << sh_idx; 285 285 const u32 rdsta_pr = RDSTA_PR0 << sh_idx; 286 286 const u32 rdsta_mask = rdsta_if | rdsta_pr; 287 + 288 + /* Clear the contents before using the descriptor */ 289 + memset(desc, 0x00, CAAM_CMD_SZ * 7); 290 + 287 291 /* 288 292 * If the corresponding bit is set, this state handle 289 293 * was initialized by somebody else, so it's left alone. ··· 331 327 } 332 328 333 329 dev_info(ctrldev, "Instantiated RNG4 SH%d\n", sh_idx); 334 - /* Clear the contents before recreating the descriptor */ 335 - memset(desc, 0x00, CAAM_CMD_SZ * 7); 336 330 } 337 331 338 332 kfree(desc);