add some sizes to free.

as a bonus, an xxx comment where i believe there's a leak.


Index: aesni.c
===================================================================
RCS file: /cvs/src/sys/arch/amd64/amd64/aesni.c,v
retrieving revision 1.32
diff -u -p -r1.32 aesni.c
--- aesni.c     14 Mar 2015 03:38:46 -0000      1.32
+++ aesni.c     27 Aug 2015 23:24:18 -0000
@@ -160,7 +160,8 @@ aesni_setup(void)
 
        aesni_sc->sc_cid = crypto_get_driverid(0);
        if (aesni_sc->sc_cid < 0) {
-               free(aesni_sc, M_DEVBUF, 0);
+               /* xxx free aesni_sc->sc_buf */
+               free(aesni_sc, M_DEVBUF, sizeof(*aesni_sc));
                return;
        }
 
@@ -350,12 +351,12 @@ aesni_freesession(u_int64_t tid)
 
        if (ses->ses_ghash) {
                explicit_bzero(ses->ses_ghash, sizeof(GHASH_CTX));
-               free(ses->ses_ghash, M_CRYPTO_DATA, 0);
+               free(ses->ses_ghash, M_CRYPTO_DATA, sizeof(GHASH_CTX));
        }
 
        if (ses->ses_xts) {
                explicit_bzero(ses->ses_xts, sizeof(struct aesni_xts_ctx));
-               free(ses->ses_xts, M_CRYPTO_DATA, 0);
+               free(ses->ses_xts, M_CRYPTO_DATA, sizeof(struct aesni_xts_ctx));
        }
 
        if (ses->ses_swd) {
@@ -364,13 +365,13 @@ aesni_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(ses, sizeof (*ses));
@@ -409,7 +410,7 @@ aesni_encdec(struct cryptop *crp, struct
        if (crd->crd_len > aesni_sc->sc_buflen) {
                if (buf != NULL) {
                        explicit_bzero(buf, aesni_sc->sc_buflen);
-                       free(buf, M_DEVBUF, 0);
+                       free(buf, M_DEVBUF, aesni_sc->sc_buflen);
                }
 
                aesni_sc->sc_buflen = 0;
Index: est.c
===================================================================
RCS file: /cvs/src/sys/arch/amd64/amd64/est.c,v
retrieving revision 1.36
diff -u -p -r1.36 est.c
--- est.c       14 Mar 2015 03:38:46 -0000      1.36
+++ est.c       27 Aug 2015 23:26:43 -0000
@@ -253,7 +253,7 @@ est_acpi_init()
        return acpilist;
 
 notable:
-       free(acpilist, M_DEVBUF, 0);
+       free(acpilist, M_DEVBUF, sizeof(struct fqlist));
        acpilist = NULL;
 nolist:
        return NULL;
@@ -281,7 +281,7 @@ est_acpi_pss_changed(struct acpicpu_pss 
            M_DEVBUF, M_NOWAIT)) == NULL) {
                printf("est_acpi_pss_changed: cannot allocate memory for new "
                    "operating points");
-               free(acpilist, M_DEVBUF, 0);
+               free(acpilist, M_DEVBUF, sizeof(struct fqlist));
                return;
        }
 
@@ -292,8 +292,8 @@ est_acpi_pss_changed(struct acpicpu_pss 
                        needtran = 0;
        }
 
-       free(est_fqlist->table, M_DEVBUF, 0);
-       free(est_fqlist, M_DEVBUF, 0);
+       free(est_fqlist->table, M_DEVBUF, npss * sizeof(struct est_op));
+       free(est_fqlist, M_DEVBUF, sizeof(struct fqlist));
        est_fqlist = acpilist;
 
        if (needtran) {
@@ -381,7 +381,7 @@ est_init(struct cpu_info *ci)
 
                if ((fake_table = malloc(sizeof(struct est_op) * 3, M_DEVBUF,
                     M_NOWAIT)) == NULL) {
-                       free(fake_fqlist, M_DEVBUF, 0);
+                       free(fake_fqlist, M_DEVBUF, sizeof(struct fqlist));
                        printf("%s: EST: cannot allocate memory for fake "
                            "table\n", cpu_device);
                        return;
Index: intr.c
===================================================================
RCS file: /cvs/src/sys/arch/amd64/amd64/intr.c,v
retrieving revision 1.43
diff -u -p -r1.43 intr.c
--- intr.c      16 Jul 2015 05:10:14 -0000      1.43
+++ intr.c      27 Aug 2015 23:20:42 -0000
@@ -307,7 +307,7 @@ other:
 found:
                idtvec = idt_vec_alloc(APIC_LEVEL(level), IDT_INTR_HIGH);
                if (idtvec == 0) {
-                       free(ci->ci_isources[slot], M_DEVBUF, 0);
+                       free(ci->ci_isources[slot], M_DEVBUF, sizeof (struct 
intrsource));
                        ci->ci_isources[slot] = NULL;
                        return EBUSY;
                }
@@ -367,7 +367,7 @@ intr_establish(int legacy_irq, struct pi
 
        if (source->is_handlers != NULL &&
            source->is_pic->pic_type != pic->pic_type) {
-               free(ih, M_DEVBUF, 0);
+               free(ih, M_DEVBUF, sizeof *ih);
                printf("intr_establish: can't share intr source between "
                       "different PIC types (legacy_irq %d pin %d slot %d)\n",
                    legacy_irq, pin, slot);
@@ -392,7 +392,7 @@ intr_establish(int legacy_irq, struct pi
                        printf("intr_establish: pic %s pin %d: can't share "
                               "type %d with %d\n", pic->pic_name, pin,
                                source->is_type, type);
-                       free(ih, M_DEVBUF, 0);
+                       free(ih, M_DEVBUF, sizeof *ih);
                        return NULL;
                }
                break;
@@ -500,14 +500,14 @@ intr_disestablish(struct intrhand *ih)
 #endif
 
        if (source->is_handlers == NULL) {
-               free(source, M_DEVBUF, 0);
+               free(source, M_DEVBUF, sizeof (struct intrsource));
                ci->ci_isources[ih->ih_slot] = NULL;
                if (pic != &i8259_pic)
                        idt_vec_free(idtvec);
        }
 
        evcount_detach(&ih->ih_count);
-       free(ih, M_DEVBUF, 0);
+       free(ih, M_DEVBUF, sizeof *ih);
 }
 
 int

Reply via email to