summaryrefslogtreecommitdiff
path: root/ipc/mach_port.c
diff options
context:
space:
mode:
Diffstat (limited to 'ipc/mach_port.c')
-rw-r--r--ipc/mach_port.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/ipc/mach_port.c b/ipc/mach_port.c
index d902e220..c5688c90 100644
--- a/ipc/mach_port.c
+++ b/ipc/mach_port.c
@@ -205,11 +205,14 @@ mach_port_names(
size = size_needed;
kr = vm_allocate(ipc_kernel_map, &addr1, size, TRUE);
- if (kr != KERN_SUCCESS)
+ if (kr != KERN_SUCCESS) {
+ printf_once("no more room in ipc_kernel_map\n");
return KERN_RESOURCE_SHORTAGE;
+ }
kr = vm_allocate(ipc_kernel_map, &addr2, size, TRUE);
if (kr != KERN_SUCCESS) {
+ printf_once("no more room in ipc_kernel_map\n");
kmem_free(ipc_kernel_map, addr1, size);
return KERN_RESOURCE_SHORTAGE;
}
@@ -552,6 +555,8 @@ mach_port_allocate(space, right, namep)
* KERN_INVALID_NAME The name doesn't denote a right.
*/
+static volatile int mach_port_deallocate_debug = 0;
+
kern_return_t
mach_port_destroy(
ipc_space_t space,
@@ -564,8 +569,14 @@ mach_port_destroy(
return KERN_INVALID_TASK;
kr = ipc_right_lookup_write(space, name, &entry);
- if (kr != KERN_SUCCESS)
+ if (kr != KERN_SUCCESS) {
+ if (name != MACH_PORT_NULL && name != MACH_PORT_DEAD && space == current_space()) {
+ printf("task %p destroying an invalid port %u, most probably a bug.\n", current_task(), name);
+ if (mach_port_deallocate_debug)
+ SoftDebugger("mach_port_deallocate");
+ }
return kr;
+ }
/* space is write-locked and active */
kr = ipc_right_destroy(space, name, entry); /* unlocks space */
@@ -590,7 +601,6 @@ mach_port_destroy(
* KERN_INVALID_RIGHT The right isn't correct.
*/
-static volatile int mach_port_deallocate_debug = 0;
kern_return_t
mach_port_deallocate(
ipc_space_t space,
@@ -604,7 +614,7 @@ mach_port_deallocate(
kr = ipc_right_lookup_write(space, name, &entry);
if (kr != KERN_SUCCESS) {
- if (name != MACH_PORT_NULL && name != MACH_PORT_DEAD) {
+ if (name != MACH_PORT_NULL && name != MACH_PORT_DEAD && space == current_space()) {
printf("task %p deallocating an invalid port %u, most probably a bug.\n", current_task(), name);
if (mach_port_deallocate_debug)
SoftDebugger("mach_port_deallocate");
@@ -975,8 +985,10 @@ mach_port_get_set_status(
ipc_pset_t pset;
kr = vm_allocate(ipc_kernel_map, &addr, size, TRUE);
- if (kr != KERN_SUCCESS)
+ if (kr != KERN_SUCCESS) {
+ printf_once("no more room in ipc_kernel_map\n");
return KERN_RESOURCE_SHORTAGE;
+ }
/* can't fault while we hold locks */