From: "Jan Beulich" Subject: [PATCH] x86/powernow: fix machine shutdown Date: Mon, 27 Oct 2008 11:31:49 +0000 Message-ID: <4905B4B5.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org cpufreq_del_cpu() calls cpufreq_driver->exit() without checking whether an exit() handler is present, and by adding an exit() handler to powernow we can at once close the potential memory leak. Signed-off-by: Jan Beulich Index: 2008-09-19/xen/arch/x86/acpi/cpufreq/powernow.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2008-09-19.orig/xen/arch/x86/acpi/cpufreq/powernow.c 2008-09-19 = 15:44:48.000000000 +0200 +++ 2008-09-19/xen/arch/x86/acpi/cpufreq/powernow.c 2008-10-14 = 14:36:04.000000000 +0200 @@ -229,9 +229,23 @@ err_unreg: return result; } =20 +static int powernow_cpufreq_cpu_exit(struct cpufreq_policy *policy) +{ + struct powernow_cpufreq_data *data =3D drv_data[policy->cpu]; + + if (data) { + drv_data[policy->cpu] =3D NULL; + xfree(data->freq_table); + xfree(data); + } + + return 0; +} + static struct cpufreq_driver powernow_cpufreq_driver =3D { .target =3D powernow_cpufreq_target, .init =3D powernow_cpufreq_cpu_init, + .exit =3D powernow_cpufreq_cpu_exit }; =20 int powernow_cpufreq_init(void)