summaryrefslogtreecommitdiff
path: root/ipc
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2015-01-21 00:09:10 +0100
committerJustus Winter <4winter@informatik.uni-hamburg.de>2015-01-22 23:40:04 +0100
commit023f1fd20f8ffc29e2daa383756599cf14888418 (patch)
tree115103ed03f1699ea9c1a01e8a30b7f9b4869cb2 /ipc
parent87b7d8226c4219fdf7b6f607a437e9c93c9211d7 (diff)
ipc: warn about more port management bugs
* ipc/mach_port.c (mach_port_destroy): Simplify expression. Reword warning. (mach_port_deallocate): Likewise. (mach_port_mod_refs): Also warn about errors when using this function.
Diffstat (limited to 'ipc')
-rw-r--r--ipc/mach_port.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/ipc/mach_port.c b/ipc/mach_port.c
index c7d9b81..4e89527 100644
--- a/ipc/mach_port.c
+++ b/ipc/mach_port.c
@@ -570,8 +570,8 @@ mach_port_destroy(
kr = ipc_right_lookup_write(space, name, &entry);
if (kr != KERN_SUCCESS) {
- if (name != MACH_PORT_NULL && name != MACH_PORT_DEAD && space == current_space()) {
- printf("task %.*s destroying an invalid port %lu, most probably a bug.\n", sizeof current_task()->name, current_task()->name, name);
+ if (MACH_PORT_VALID (name) && space == current_space()) {
+ printf("task %.*s destroying a bogus port %lu, most probably a bug.\n", sizeof current_task()->name, current_task()->name, name);
if (mach_port_deallocate_debug)
SoftDebugger("mach_port_deallocate");
}
@@ -614,8 +614,8 @@ mach_port_deallocate(
kr = ipc_right_lookup_write(space, name, &entry);
if (kr != KERN_SUCCESS) {
- if (name != MACH_PORT_NULL && name != MACH_PORT_DEAD && space == current_space()) {
- printf("task %.*s deallocating an invalid port %lu, most probably a bug.\n", sizeof current_task()->name, current_task()->name, name);
+ if (MACH_PORT_VALID (name) && space == current_space()) {
+ printf("task %.*s deallocating a bogus port %lu, most probably a bug.\n", sizeof current_task()->name, current_task()->name, name);
if (mach_port_deallocate_debug)
SoftDebugger("mach_port_deallocate");
}
@@ -735,8 +735,19 @@ mach_port_mod_refs(
return KERN_INVALID_VALUE;
kr = ipc_right_lookup_write(space, name, &entry);
- if (kr != KERN_SUCCESS)
+ if (kr != KERN_SUCCESS) {
+ if (MACH_PORT_VALID (name) && space == current_space()) {
+ printf("task %.*s %screasing a bogus port "
+ "%lu by %d, most probably a bug.\n",
+ sizeof current_task()->name,
+ current_task()->name,
+ delta < 0 ? "de" : "in", name,
+ delta < 0 ? -delta : delta);
+ if (mach_port_deallocate_debug)
+ SoftDebugger("mach_port_mod_refs");
+ }
return kr;
+ }
/* space is write-locked and active */
kr = ipc_right_delta(space, name, entry, right, delta); /* unlocks */