summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_bus.c
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>1999-08-14 05:11:01 +0000
committerwpaul <wpaul@FreeBSD.org>1999-08-14 05:11:01 +0000
commita8658ef38fcdfabe89e91d8440a3905812598ba1 (patch)
tree1f42ea43704e7e3aba9d0a82e9fd054800935680 /sys/kern/subr_bus.c
parent4e587dfae44f93451453de52e80c031df3976774 (diff)
downloadFreeBSD-src-a8658ef38fcdfabe89e91d8440a3905812598ba1.zip
FreeBSD-src-a8658ef38fcdfabe89e91d8440a3905812598ba1.tar.gz
Grrrr. Fix a really lame bug that I tripped over while testing my miibus
stuff: unregister_methods() is horribly broken. The idea, if I'm not mistaken, is that the refcount on a method is decremented, and only when it reaches zero is the method freed. However desc->method is set to NULL unconditionally regardless of the refcount, which means the method pointer is trashed the first time the method is deallocated. The obvious detrimental effect is that memory is leaked. The not so obvious effect is that when you call unregister_method() the second time on the same method, you get a NULL pointer dereference and a panic. Now I can successfully unload network device drivers and the miibus module without crashing the system. *sigh*
Diffstat (limited to 'sys/kern/subr_bus.c')
-rw-r--r--sys/kern/subr_bus.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index 3044ada..f7fda58 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: subr_bus.c,v 1.34 1999/08/11 22:05:17 peter Exp $
+ * $Id: subr_bus.c,v 1.35 1999/08/11 22:55:39 peter Exp $
*/
#include <sys/param.h>
@@ -159,8 +159,8 @@ unregister_method(struct device_op_desc *desc)
if (m->refs == 0) {
LIST_REMOVE(m, link);
free(m, M_DEVBUF);
+ desc->method = 0;
}
- desc->method = 0;
}
static int error_method(void)
OpenPOWER on IntegriCloud