i386/118737: [ PATCH ] Panic due double free within detach of cpufreq/est

Dan Lukes dan at obluda.cz
Sat Dec 15 18:30:01 PST 2007


>Number:         118737
>Category:       i386
>Synopsis:       [ PATCH ] Panic due double free within detach of cpufreq/est
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-i386
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Dec 16 02:30:00 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator:     Dan Lukes
>Release:        FreeBSD 6.3-PRERELEASE i386
>Organization:
Obludarium
>Environment:
System: FreeBSD 6.3-PRERELEASE #18: Sun Dec 16 03:05:00 CET 2007 i386
src/sys/i386/cpufreq/est.c,v 1.7.2.1 2006/05/29 22:40:03 njl

As far as I know the problem apply to CURRENT as well

>Description:

  on est_detach the sc->freq_list freed but driver cease to detach (ENXIO)

  on second try to unload driver the memory is freed second time causing
the panic()

>How-To-Repeat:
	On hardware supported by est driver unload cpufreq module - it fail with ENXIO
	unload it second time - it will panic

>Fix:

	Unregister the driver properly then return NOERROR to upper layer.

--- sys/i386/cpufreq/est.c.ORIG	2007-12-16 02:13:42.000000000 +0100
+++ sys/i386/cpufreq/est.c	2007-12-16 02:26:46.000000000 +0100
@@ -1032,11 +1032,14 @@
 est_detach(device_t dev)
 {
 	struct est_softc *sc;
+	int error;
 
 	sc = device_get_softc(dev);
-	if (sc->acpi_settings)
+
+	error = cpufreq_unregister(dev);
+	if (!error && sc->acpi_settings)
 		free(sc->freq_list, M_DEVBUF);
-	return (ENXIO);
+	return (error);
 }
 
 /*


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-i386 mailing list