diff options
author | 2014-10-30 17:23:45 +0000 | |
---|---|---|
committer | 2014-10-30 17:23:45 +0000 | |
commit | 939b6ccfef172337e2a8fe49ff97e303a8175d7a (patch) | |
tree | 8e91c5aeeb2e84222e7047dd9b653212d900c924 | |
parent | Fix whitespace errors in libevent. (diff) | |
download | wireguard-openbsd-939b6ccfef172337e2a8fe49ff97e303a8175d7a.tar.xz wireguard-openbsd-939b6ccfef172337e2a8fe49ff97e303a8175d7a.zip |
add some sizes to free()
-rw-r--r-- | sys/dev/softraid.c | 28 | ||||
-rw-r--r-- | sys/dev/softraid_crypto.c | 29 |
2 files changed, 24 insertions, 33 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c index 7ff4fae6e89..81436a0f056 100644 --- a/sys/dev/softraid.c +++ b/sys/dev/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.341 2014/10/07 20:23:32 tedu Exp $ */ +/* $OpenBSD: softraid.c,v 1.342 2014/10/30 17:23:45 tedu Exp $ */ /* * Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org> @@ -523,7 +523,7 @@ sr_meta_clear(struct sr_discipline *sd) bzero(sd->sd_meta, SR_META_SIZE * 512); - free(m, M_DEVBUF, 0); + free(m, M_DEVBUF, SR_META_SIZE * 512); rv = 0; done: return (rv); @@ -726,7 +726,7 @@ restart: wu.swu_dis = sd; sd->sd_scsi_sync(&wu); } - free(m, M_DEVBUF, 0); + free(m, M_DEVBUF, SR_META_SIZE * 512); return (0); bad: return (1); @@ -797,9 +797,8 @@ sr_meta_read(struct sr_discipline *sd) cp++; } - free(sm, M_DEVBUF, 0); - if (fm) - free(fm, M_DEVBUF, 0); + free(sm, M_DEVBUF, SR_META_SIZE * 512); + free(fm, M_DEVBUF, s->smd_size); done: DNPRINTF(SR_D_META, "%s: sr_meta_read found %d parts\n", DEVNAME(sc), @@ -1128,10 +1127,8 @@ sr_meta_native_bootprobe(struct sr_softc *sc, dev_t devno, } done: - if (fake_sd) - free(fake_sd, M_DEVBUF, 0); - if (md) - free(md, M_DEVBUF, 0); + free(fake_sd, M_DEVBUF, sizeof(struct sr_discipline)); + free(md, M_DEVBUF, SR_META_SIZE * 512); return (rv); } @@ -1493,10 +1490,8 @@ unwind: free(sdk, M_DEVBUF, 0); } - if (devs) - free(devs, M_DEVBUF, 0); - if (ondisk) - free(ondisk, M_DEVBUF, 0); + free(devs, M_DEVBUF, BIOC_CRMAXLEN); + free(ondisk, M_DEVBUF, BIOC_CRMAXLEN * sizeof(u_int64_t)); return (rv); } @@ -1692,8 +1687,7 @@ sr_meta_native_attach(struct sr_discipline *sd, int force) rv = 0; bad: - if (md) - free(md, M_DEVBUF, 0); + free(md, M_DEVBUF, SR_META_SIZE * 512); return (rv); } @@ -4448,7 +4442,7 @@ sr_uuid_print(struct sr_uuid *uuid, int cr) uuidstr = sr_uuid_format(uuid); printf("%s%s", uuidstr, (cr ? "\n" : "")); - free(uuidstr, M_DEVBUF, 0); + free(uuidstr, M_DEVBUF, 37); } int diff --git a/sys/dev/softraid_crypto.c b/sys/dev/softraid_crypto.c index 7ddaf0043b2..5887c609b75 100644 --- a/sys/dev/softraid_crypto.c +++ b/sys/dev/softraid_crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_crypto.c,v 1.112 2014/09/14 14:17:24 jsg Exp $ */ +/* $OpenBSD: softraid_crypto.c,v 1.113 2014/10/30 17:23:45 tedu Exp $ */ /* * Copyright (c) 2007 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Hans-Joerg Hoexer <hshoexer@openbsd.org> @@ -356,7 +356,7 @@ sr_crypto_get_kdf(struct bioc_createraid *bc, struct sr_discipline *sd) rv = 0; out: explicit_bzero(kdfinfo, bc->bc_opaque_size); - free(kdfinfo, M_DEVBUF, 0); + free(kdfinfo, M_DEVBUF, bc->bc_opaque_size); return (rv); } @@ -590,7 +590,7 @@ sr_crypto_change_maskkey(struct sr_discipline *sd, out: if (p) { explicit_bzero(p, ksz); - free(p, M_DEVBUF, 0); + free(p, M_DEVBUF, ksz); } explicit_bzero(check_digest, sizeof(check_digest)); @@ -751,19 +751,16 @@ sr_crypto_create_key_disk(struct sr_discipline *sd, dev_t dev) goto done; fail: - if (key_disk) - free(key_disk, M_DEVBUF, 0); + free(key_disk, M_DEVBUF, sizeof(struct sr_chunk)); key_disk = NULL; done: - if (omi) - free(omi, M_DEVBUF, 0); + free(omi, M_DEVBUF, sizeof(struct sr_meta_opt_item)); if (fakesd && fakesd->sd_vol.sv_chunks) - free(fakesd->sd_vol.sv_chunks, M_DEVBUF, 0); - if (fakesd) - free(fakesd, M_DEVBUF, 0); - if (sm) - free(sm, M_DEVBUF, 0); + free(fakesd->sd_vol.sv_chunks, M_DEVBUF, + sizeof(struct sr_chunk *)); + free(fakesd, M_DEVBUF, sizeof(struct sr_discipline)); + free(sm, M_DEVBUF, sizeof(struct sr_metadata)); if (open) { VOP_CLOSE(vn, FREAD | FWRITE, NOCRED, curproc); vput(vn); @@ -893,8 +890,7 @@ done: free(omi, M_DEVBUF, 0); } - if (sm) - free(sm, M_DEVBUF, 0); + free(sm, M_DEVBUF, SR_META_SIZE * 512); if (vn && open) { VOP_CLOSE(vn, FREAD, NOCRED, curproc); @@ -999,8 +995,9 @@ sr_crypto_free_resources(struct sr_discipline *sd) DEVNAME(sd->sd_sc)); if (sd->mds.mdd_crypto.key_disk != NULL) { - explicit_bzero(sd->mds.mdd_crypto.key_disk, sizeof - sd->mds.mdd_crypto.key_disk); + explicit_bzero(sd->mds.mdd_crypto.key_disk, + sizeof(sd->mds.mdd_crypto.key_disk)); + /* XXX correct size? XXX */ free(sd->mds.mdd_crypto.key_disk, M_DEVBUF, 0); } |