From c9c3ce79765d2f3c2714281f19dcaf711a090ac2 Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Tue, 10 Jan 2023 14:06:53 -0500 Subject: [PATCH] Cleanup: Use kmem_zalloc() instead of memset() to zero memory The Linux 5.16.14 kernel's coccicheck caught this. The semantic patch that caught it was: ./scripts/coccinelle/api/alloc/zalloc-simple.cocci Reviewed-by: Brian Behlendorf Signed-off-by: Richard Yao Closes #14372 --- module/os/freebsd/zfs/zio_crypt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/module/os/freebsd/zfs/zio_crypt.c b/module/os/freebsd/zfs/zio_crypt.c index c5e745f7d1..fdbe13dbb5 100644 --- a/module/os/freebsd/zfs/zio_crypt.c +++ b/module/os/freebsd/zfs/zio_crypt.c @@ -1555,13 +1555,12 @@ zio_crypt_init_uios_normal(boolean_t encrypt, uint8_t *plainbuf, iovec_t *plain_iovecs = NULL, *cipher_iovecs = NULL; void *src, *dst; - cipher_iovecs = kmem_alloc(nr_cipher * sizeof (iovec_t), + cipher_iovecs = kmem_zalloc(nr_cipher * sizeof (iovec_t), KM_SLEEP); if (!cipher_iovecs) { ret = SET_ERROR(ENOMEM); goto error; } - memset(cipher_iovecs, 0, nr_cipher * sizeof (iovec_t)); if (encrypt) { src = plainbuf;