diff options
| author | Maxime Henrion <mux@FreeBSD.org> | 2003-05-29 21:19:18 +0000 |
|---|---|---|
| committer | Maxime Henrion <mux@FreeBSD.org> | 2003-05-29 21:19:18 +0000 |
| commit | 193f2edbf9d367c5b56dd899a0fc8ba18ab8e1a7 (patch) | |
| tree | 8cbeded88d20e0cef689f31e25f6207e0a622d9a | |
| parent | 1b2a19ce0e59a7ed116975bc4c27d7f939c6da8c (diff) | |
Notes
| -rw-r--r-- | sys/kern/kern_sysctl.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 26b309c74205..ab585e182db9 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -153,7 +153,30 @@ sysctl_register_oid(struct sysctl_oid *oidp) void sysctl_unregister_oid(struct sysctl_oid *oidp) { - SLIST_REMOVE(oidp->oid_parent, oidp, sysctl_oid, oid_link); + struct sysctl_oid *p; + int error; + + error = ENOENT; + if (oidp->oid_number == OID_AUTO) { + error = EINVAL; + } else { + SLIST_FOREACH(p, oidp->oid_parent, oid_link) { + if (p == oidp) { + SLIST_REMOVE(oidp->oid_parent, oidp, + sysctl_oid, oid_link); + error = 0; + break; + } + } + } + + /* + * This can happen when a module fails to register and is + * being unloaded afterwards. It should not be a panic() + * for normal use. + */ + if (error) + printf("%s: failed to unregister sysctl\n", __func__); } /* Initialize a new context to keep track of dynamically added sysctls. */ |
