Re: Add sizes for free() in the VIA PadLock driver

2017-11-12 Thread Mike Belopuhov
On Sun, Nov 12, 2017 at 21:53 +0100, Frederic Cambus wrote:
> Hi tech@,
> 
> Add sizes for free() in the VIA PadLock driver.
> 
> Comments? OK?
> 

OK mikeb.



Add sizes for free() in the VIA PadLock driver

2017-11-12 Thread Frederic Cambus
Hi tech@,

Add sizes for free() in the VIA PadLock driver.

Comments? OK?

Index: sys/arch/amd64/amd64/via.c
===
RCS file: /cvs/src/sys/arch/amd64/amd64/via.c,v
retrieving revision 1.24
diff -u -p -r1.24 via.c
--- sys/arch/amd64/amd64/via.c  14 Oct 2017 04:44:43 -  1.24
+++ sys/arch/amd64/amd64/via.c  12 Nov 2017 20:18:37 -
@@ -144,7 +144,7 @@ viac3_crypto_newsession(u_int32_t *sidp,
return (ENOMEM);
memcpy(ses, sc->sc_sessions, sesn * sizeof(*ses));
explicit_bzero(sc->sc_sessions, sesn * sizeof(*ses));
-   free(sc->sc_sessions, M_DEVBUF, 0);
+   free(sc->sc_sessions, M_DEVBUF, sesn * sizeof(*ses));
sc->sc_sessions = ses;
ses = >sc_sessions[sesn];
sc->sc_nsessions++;
@@ -284,13 +284,13 @@ viac3_crypto_freesession(u_int64_t tid)
 
if (swd->sw_ictx) {
explicit_bzero(swd->sw_ictx, axf->ctxsize);
-   free(swd->sw_ictx, M_CRYPTO_DATA, 0);
+   free(swd->sw_ictx, M_CRYPTO_DATA, axf->ctxsize);
}
if (swd->sw_octx) {
explicit_bzero(swd->sw_octx, axf->ctxsize);
-   free(swd->sw_octx, M_CRYPTO_DATA, 0);
+   free(swd->sw_octx, M_CRYPTO_DATA, axf->ctxsize);
}
-   free(swd, M_CRYPTO_DATA, 0);
+   free(swd, M_CRYPTO_DATA, sizeof(*swd));
}
 
explicit_bzero(>sc_sessions[sesn], sizeof(sc->sc_sessions[sesn]));
@@ -411,7 +411,7 @@ viac3_crypto_encdec(struct cryptop *crp,
 
if (sc->op_buf != NULL) {
explicit_bzero(sc->op_buf, crd->crd_len);
-   free(sc->op_buf, M_DEVBUF, 0);
+   free(sc->op_buf, M_DEVBUF, crd->crd_len);
sc->op_buf = NULL;
}