git: 4c6b5076b714 - stable/13 - wg: Use zfree.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Fri, 11 Nov 2022 22:04:23 UTC
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=4c6b5076b714c037c856f5854135c7522a63cbbc

commit 4c6b5076b714c037c856f5854135c7522a63cbbc
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-10-28 20:36:13 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-11-11 21:49:44 +0000

    wg: Use zfree.
    
    Reviewed by:    kevans, markj, emaste
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D36911
    
    (cherry picked from commit dcf581bb49bedcf9c18d6cccc80a9fbd68516d23)
---
 sys/dev/wg/if_wg.c    | 6 ++----
 sys/dev/wg/wg_noise.c | 9 +++------
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/sys/dev/wg/if_wg.c b/sys/dev/wg/if_wg.c
index acb1423ba40e..61828aa03496 100644
--- a/sys/dev/wg/if_wg.c
+++ b/sys/dev/wg/if_wg.c
@@ -2454,8 +2454,7 @@ out_locked:
 	sx_xunlock(&sc->sc_lock);
 	nvlist_destroy(nvl);
 out:
-	explicit_bzero(nvlpacked, wgd->wgd_size);
-	free(nvlpacked, M_TEMP);
+	zfree(nvlpacked, M_TEMP);
 	return (err);
 }
 
@@ -2579,8 +2578,7 @@ wgc_get(struct wg_softc *sc, struct wg_data_io *wgd)
 	wgd->wgd_size = size;
 
 out:
-	explicit_bzero(packed, size);
-	free(packed, M_NVLIST);
+	zfree(packed, M_NVLIST);
 err:
 	nvlist_destroy(nvl);
 	return (err);
diff --git a/sys/dev/wg/wg_noise.c b/sys/dev/wg/wg_noise.c
index 095da9dd4a7b..73ee712b11e9 100644
--- a/sys/dev/wg/wg_noise.c
+++ b/sys/dev/wg/wg_noise.c
@@ -223,8 +223,7 @@ noise_local_put(struct noise_local *l)
 		rw_destroy(&l->l_identity_lock);
 		mtx_destroy(&l->l_remote_mtx);
 		mtx_destroy(&l->l_index_mtx);
-		explicit_bzero(l, sizeof(*l));
-		free(l, M_NOISE);
+		zfree(l, M_NOISE);
 	}
 }
 
@@ -472,8 +471,7 @@ noise_remote_smr_free(struct epoch_context *smr)
 	noise_local_put(r->r_local);
 	rw_destroy(&r->r_handshake_lock);
 	mtx_destroy(&r->r_keypair_mtx);
-	explicit_bzero(r, sizeof(*r));
-	free(r, M_NOISE);
+	zfree(r, M_NOISE);
 }
 
 void
@@ -754,8 +752,7 @@ noise_keypair_smr_free(struct epoch_context *smr)
 	kp = __containerof(smr, struct noise_keypair, kp_smr);
 	noise_remote_put(kp->kp_remote);
 	rw_destroy(&kp->kp_nonce_lock);
-	explicit_bzero(kp, sizeof(*kp));
-	free(kp, M_NOISE);
+	zfree(kp, M_NOISE);
 }
 
 void