summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_bus.c
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2003-10-14 06:22:07 +0000
committerimp <imp@FreeBSD.org>2003-10-14 06:22:07 +0000
commite34b12b9cdb507666a4eafdf2f1e52a113dcb791 (patch)
tree307fe3b30fb987d8e92844e43f5002a1cea9e372 /sys/kern/subr_bus.c
parent3d04ccf49a829c48f61f9b0341cc3b095ca6eb5f (diff)
downloadFreeBSD-src-e34b12b9cdb507666a4eafdf2f1e52a113dcb791.zip
FreeBSD-src-e34b12b9cdb507666a4eafdf2f1e52a113dcb791.tar.gz
With DIAGNOSTICS, sometimes we get weird crashes when some driver
accesses softc after it is freed. Use a different malloc type for softc than the rest of the bus code to make it more clear when these things happen that it is the driver that's at fault, not the bus code. Suggested by: sam and/or phk (I think)
Diffstat (limited to 'sys/kern/subr_bus.c')
-rw-r--r--sys/kern/subr_bus.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index 7bb7704..03049bf 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -132,6 +132,7 @@ struct device_op_desc {
};
static MALLOC_DEFINE(M_BUS, "bus", "Bus data structures");
+static MALLOC_DEFINE(M_BUS_SC, "bus-sc", "Bus data structures, softc");
#ifdef BUS_DEBUG
@@ -1257,7 +1258,7 @@ void
device_set_softc(device_t dev, void *softc)
{
if (dev->softc && !(dev->flags & DF_EXTERNALSOFTC))
- free(dev->softc, M_BUS);
+ free(dev->softc, M_BUS_SC);
dev->softc = softc;
if (dev->softc)
dev->flags |= DF_EXTERNALSOFTC;
@@ -1396,7 +1397,7 @@ device_set_driver(device_t dev, driver_t *driver)
return (0);
if (dev->softc && !(dev->flags & DF_EXTERNALSOFTC)) {
- free(dev->softc, M_BUS);
+ free(dev->softc, M_BUS_SC);
dev->softc = NULL;
}
kobj_delete((kobj_t) dev, 0);
@@ -1404,7 +1405,7 @@ device_set_driver(device_t dev, driver_t *driver)
if (driver) {
kobj_init((kobj_t) dev, (kobj_class_t) driver);
if (!(dev->flags & DF_EXTERNALSOFTC) && driver->size > 0) {
- dev->softc = malloc(driver->size, M_BUS,
+ dev->softc = malloc(driver->size, M_BUS_SC,
M_NOWAIT | M_ZERO);
if (!dev->softc) {
kobj_delete((kobj_t) dev, 0);
OpenPOWER on IntegriCloud