]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/ipc_sync.c
xnu-2050.7.9.tar.gz
[apple/xnu.git] / osfmk / kern / ipc_sync.c
index b2774b520a89b60398f388b8a3ab1cc6175b4a96..ab24fe06f263a44eb220b066c7b64ad262d768c2 100644 (file)
@@ -104,11 +104,12 @@ convert_semaphore_to_port (semaphore_t semaphore)
 {
        ipc_port_t port;
 
-       if (semaphore != SEMAPHORE_NULL)
-               port = ipc_port_make_send(semaphore->port);
-       else
-               port = IP_NULL;
+       if (semaphore == SEMAPHORE_NULL)
+               return (IP_NULL);
 
+       /* caller is donating a reference */
+       port = ipc_port_make_send(semaphore->port);
+       semaphore_dereference(semaphore);
        return (port);
 }
 
@@ -134,11 +135,12 @@ convert_lock_set_to_port (lock_set_t lock_set)
 {
        ipc_port_t port;
 
-       if (lock_set != LOCK_SET_NULL)
-               port = ipc_port_make_send(lock_set->port);
-       else
-               port = IP_NULL;
+       if (lock_set == LOCK_SET_NULL)
+               return IP_NULL;
 
+       /* caller is donating a reference */
+       port = ipc_port_make_send(lock_set->port);
+       lock_set_dereference(lock_set);
        return (port);
 }