Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/cddl/osnet/dev/dtrace When loading the module, if d...
details: https://anonhg.NetBSD.org/src/rev/eb56840b1bdc
branches: trunk
changeset: 341912:eb56840b1bdc
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Sat Nov 28 22:41:36 2015 +0000
description:
When loading the module, if devsw_attach() fails, call dtrace_unload()
to undo the effects of dtrace_load(). And if dtrace_unload() fails,
panic (since we can't get the system back to its earlier stable state).
When unloading the module, call devsw_detach() first, to lock out any
new access. Then call dtrace_unload(). If dgtrace_unload() fails,
reattach the devsw, and if that fails, panic.
Implements fixes described in PR kern/43032
diffstat:
external/cddl/osnet/dev/dtrace/dtrace_modevent.c | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
diffs (39 lines):
diff -r ed580f344c73 -r eb56840b1bdc external/cddl/osnet/dev/dtrace/dtrace_modevent.c
--- a/external/cddl/osnet/dev/dtrace/dtrace_modevent.c Sat Nov 28 21:06:30 2015 +0000
+++ b/external/cddl/osnet/dev/dtrace/dtrace_modevent.c Sat Nov 28 22:41:36 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dtrace_modevent.c,v 1.4 2015/02/26 09:10:52 ozaki-r Exp $ */
+/* $NetBSD: dtrace_modevent.c,v 1.5 2015/11/28 22:41:36 pgoyette Exp $ */
/*
* CDDL HEADER START
@@ -34,13 +34,26 @@
switch (cmd) {
case MODULE_CMD_INIT:
dtrace_load(NULL);
- return devsw_attach("dtrace", NULL, &bmajor,
+ error = devsw_attach("dtrace", NULL, &bmajor,
&dtrace_cdevsw, &cmajor);
+ if (error != 0)
+ if (dtrace_unload() != 0)
+ panic("failed to unload dtrace");
+ return error;
+
case MODULE_CMD_FINI:
- error = dtrace_unload();
+ error = devsw_detach(NULL, &dtrace_cdevsw);
if (error != 0)
return error;
- return devsw_detach(NULL, &dtrace_cdevsw);
+
+ error = dtrace_unload();
+ if (error != 0) {
+ if (devsw_attach("dtrace", NULL, &bmajor,
+ &dtrace_cdevsw, &cmajor) != 0)
+ panic("failed to reattach dtrace_devsw");
+ }
+ return error;
+
case MODULE_CMD_AUTOUNLOAD:
return EBUSY;
default:
Home |
Main Index |
Thread Index |
Old Index