From 354866860278a26b5c5efd5583afae061b47a29e Mon Sep 17 00:00:00 2001 From: dlg Date: Thu, 22 Jan 2015 01:19:51 +0000 Subject: [PATCH] bring back r1.80: pass the size of the softc to free. this time we only dereference the cfattach structure if we actually need it once the refcount has dropped to 0. tested by krw@ who found the original panic r1.80 was backed out for. putting this in again so i can find out when else will break. --- sys/kern/subr_autoconf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/kern/subr_autoconf.c b/sys/kern/subr_autoconf.c index 2c0964cea8e..49838565ae5 100644 --- a/sys/kern/subr_autoconf.c +++ b/sys/kern/subr_autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_autoconf.c,v 1.83 2015/01/19 23:01:07 deraadt Exp $ */ +/* $OpenBSD: subr_autoconf.c,v 1.84 2015/01/22 01:19:51 dlg Exp $ */ /* $NetBSD: subr_autoconf.c,v 1.21 1996/04/04 06:06:18 cgd Exp $ */ /* @@ -935,8 +935,11 @@ device_ref(struct device *dv) void device_unref(struct device *dv) { + struct cfattach *ca; + dv->dv_ref--; if (dv->dv_ref == 0) { - free(dv, M_DEVBUF, 0); + ca = dv->dv_cfdata->cf_attach; + free(dv, M_DEVBUF, ca->ca_devsize); } } -- 2.20.1