From 100eb9e53f441a1d6c6e7db55f735778d67bf504 Mon Sep 17 00:00:00 2001
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Sun, 19 Jul 2020 14:18:16 +0200
Subject: device intr: Fix reference leak

On RPC success we have to release the passed send rights, otherwise
references accumulate and we never notice when the receiver dies.

* device/ds_routines.c (ds_device_intr_ack): On success, call
ipc_port_release_send on the notification receive port.
---
 device/ds_routines.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

(limited to 'device/ds_routines.c')

diff --git a/device/ds_routines.c b/device/ds_routines.c
index 681f6260..e94e5ca8 100644
--- a/device/ds_routines.c
+++ b/device/ds_routines.c
@@ -367,6 +367,7 @@ ds_device_intr_ack (device_t dev, ipc_port_t receive_port)
   return D_INVALID_OPERATION;
 #else /* MACH_XEN || __x86_64__ */
   mach_device_t mdev = dev->emul_data;
+  kern_return_t ret;
 
   /* Refuse if device is dead or not completely open.  */
   if (dev == DEVICE_NULL)
@@ -376,7 +377,12 @@ ds_device_intr_ack (device_t dev, ipc_port_t receive_port)
   if (! name_equal(mdev->dev_ops->d_name, 3, "irq"))
     return D_INVALID_OPERATION;
 
-  return irq_acknowledge(receive_port);
+  ret = irq_acknowledge(receive_port);
+
+  if (ret == D_SUCCESS)
+    ipc_port_release_send(receive_port);
+
+  return ret;
 #endif /* MACH_XEN || __x86_64__ */
 }
 
-- 
cgit v1.2.3