From: guenther Date: Fri, 23 May 2014 03:30:41 +0000 (+0000) Subject: Free the est_fqlist allocations if we end up not using it. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7231f490c20c5f076510b31bec77bc8e520c0110;p=openbsd 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@ --- 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