diff options
author | 2014-05-23 03:30:41 +0000 | |
---|---|---|
committer | 2014-05-23 03:30:41 +0000 | |
commit | 7231f490c20c5f076510b31bec77bc8e520c0110 (patch) | |
tree | c05420e533b0263b7ae03add937325483babf025 | |
parent | don't deprecate until at least the base src tree is clean. (diff) | |
download | wireguard-openbsd-7231f490c20c5f076510b31bec77bc8e520c0110.tar.xz wireguard-openbsd-7231f490c20c5f076510b31bec77bc8e520c0110.zip |
Free the est_fqlist allocations if we end up not using it.
suggested by Benjamin Baier (programmer (at) netzbasis.de)
ok and comment suggestion kettenis@
-rw-r--r-- | sys/arch/amd64/amd64/est.c | 12 | ||||
-rw-r--r-- | sys/arch/i386/i386/est.c | 16 |
2 files changed, 22 insertions, 6 deletions
diff --git a/sys/arch/amd64/amd64/est.c b/sys/arch/amd64/amd64/est.c index d4ad12e6ed8..c5b6d822669 100644 --- a/sys/arch/amd64/amd64/est.c +++ b/sys/arch/amd64/amd64/est.c @@ -1,4 +1,4 @@ -/* $OpenBSD: est.c,v 1.31 2014/05/10 18:59:29 guenther Exp $ */ +/* $OpenBSD: est.c,v 1.32 2014/05/23 03:30:41 guenther Exp $ */ /* * Copyright (c) 2003 Michael Eriksson. * All rights reserved. @@ -418,12 +418,12 @@ est_init(struct cpu_info *ci) return; if (est_fqlist->n < 2) - return; + goto nospeedstep; low = est_fqlist->table[est_fqlist->n - 1].mhz; high = est_fqlist->table[0].mhz; if (low == high) - return; + goto nospeedstep; perflevel = (cpuspeed - low) * 100 / (high - low); @@ -439,6 +439,12 @@ est_init(struct cpu_info *ci) cpu_setperf = est_setperf; setperf_prio = 3; + + return; + +nospeedstep: + free(est_fqlist->table, M_DEVBUF); + free(est_fqlist, M_DEVBUF); } void diff --git a/sys/arch/i386/i386/est.c b/sys/arch/i386/i386/est.c index dc159fc625e..8321bdafce3 100644 --- a/sys/arch/i386/i386/est.c +++ b/sys/arch/i386/i386/est.c @@ -1,4 +1,4 @@ -/* $OpenBSD: est.c,v 1.41 2014/05/10 18:59:29 guenther Exp $ */ +/* $OpenBSD: est.c,v 1.42 2014/05/23 03:30:41 guenther Exp $ */ /* * Copyright (c) 2003 Michael Eriksson. * All rights reserved. @@ -1177,12 +1177,12 @@ est_init(struct cpu_info *ci, int vendor) return; if (est_fqlist->n < 2) - return; + goto nospeedstep; low = est_fqlist->table[est_fqlist->n - 1].mhz; high = est_fqlist->table[0].mhz; if (low == high) - return; + goto nospeedstep; perflevel = (cpuspeed - low) * 100 / (high - low); @@ -1198,6 +1198,16 @@ est_init(struct cpu_info *ci, int vendor) cpu_setperf = est_setperf; setperf_prio = 3; + + return; + +nospeedstep: + /* + * While est_fqlist can point into the static est_cpus[], + * it can't fail in that case and therefore can't reach here. + */ + free(est_fqlist->table, M_DEVBUF); + free(est_fqlist, M_DEVBUF); } void |