diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-09-28 16:59:36 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-09-28 16:59:36 +0000 |
commit | 1dfa6daa1e242f5ab4c1bf7ed4526803ef098402 (patch) | |
tree | 62cb94ec1adc8a01cdfecb5556df9e6a4c1acbbe /sys/kern | |
parent | e6c40e80164c5ccc2eb75205f47d2b3ab265e6b3 (diff) |
track sizes for free in sysctl_diskinit(); ok krw
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_sysctl.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 1eda6753042..3a716b0ac6a 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.294 2015/09/13 17:08:03 guenther Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.295 2015/09/28 16:59:35 deraadt Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -256,7 +256,9 @@ char domainname[MAXHOSTNAMELEN]; int domainnamelen; long hostid; char *disknames = NULL; +size_t disknameslen; struct diskstats *diskstats = NULL; +size_t diskstatslen; #ifdef INSECURE int securelevel = -1; #else @@ -2073,14 +2075,16 @@ sysctl_diskinit(int update, struct proc *p) tlen++; if (disknames) - free(disknames, M_SYSCTL, 0); + free(disknames, M_SYSCTL, disknameslen); if (diskstats) - free(diskstats, M_SYSCTL, 0); + free(diskstats, M_SYSCTL, diskstatslen); diskstats = NULL; disknames = NULL; diskstats = mallocarray(disk_count, sizeof(struct diskstats), M_SYSCTL, M_WAITOK); + diskstatslen = disk_count * sizeof(struct diskstats); disknames = malloc(tlen, M_SYSCTL, M_WAITOK); + disknameslen = tlen; disknames[0] = '\0'; for (dk = TAILQ_FIRST(&disklist), i = 0, l = 0; dk; |