diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2024-12-23 01:07:21 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2024-12-23 01:07:21 +0100 |
commit | 48e1c56161d40e0fb761f11a7c076553886fb7e4 (patch) | |
tree | 6ddcb4fc5bd83229c488ae4b1a6afff142d920e9 | |
parent | af488a9e8b8e0de5f0c97d07beabbe43249c4b97 (diff) | |
download | hurd-48e1c56161d40e0fb761f11a7c076553886fb7e4.tar.gz hurd-48e1c56161d40e0fb761f11a7c076553886fb7e4.tar.bz2 hurd-48e1c56161d40e0fb761f11a7c076553886fb7e4.zip |
Fix port leaks
get_privileged_ports adds a port ref, so we have to deallocate it.
-rw-r--r-- | acpi/main.c | 1 | ||||
-rw-r--r-- | daemons/console-run.c | 1 | ||||
-rw-r--r-- | libmachdev/ds_routines.c | 5 | ||||
-rw-r--r-- | pci-arbiter/main.c | 1 | ||||
-rw-r--r-- | rumpdisk/block-rump.c | 3 |
5 files changed, 10 insertions, 1 deletions
diff --git a/acpi/main.c b/acpi/main.c index 18f0afc5..a62c0700 100644 --- a/acpi/main.c +++ b/acpi/main.c @@ -96,6 +96,7 @@ acpi_device_open (mach_port_t reply_port, mach_msg_type_name_t reply_port_type, if (dev_master == MACH_PORT_NULL) return D_NO_SUCH_DEVICE; err = device_open (dev_master, mode, name, devp); + mach_port_deallocate (mach_task_self (), dev_master); if (err) return err; *devicePoly = MACH_MSG_TYPE_MOVE_SEND; diff --git a/daemons/console-run.c b/daemons/console-run.c index eab1f51d..87fd8e9f 100644 --- a/daemons/console-run.c +++ b/daemons/console-run.c @@ -37,6 +37,7 @@ get_console (void) return MACH_PORT_NULL; err = device_open (device_master, D_WRITE | D_READ, "console", &console); + mach_port_deallocate (mach_task_self (), device_master); if (err) return MACH_PORT_NULL; diff --git a/libmachdev/ds_routines.c b/libmachdev/ds_routines.c index 6555d6e9..aeb7f5af 100644 --- a/libmachdev/ds_routines.c +++ b/libmachdev/ds_routines.c @@ -119,7 +119,10 @@ ds_device_open (mach_port_t open_port, mach_port_t reply_port, { err = get_privileged_ports(NULL, &dev_master); if (!err) - err = device_open (dev_master, mode, name, devp); + { + err = device_open (dev_master, mode, name, devp); + mach_port_deallocate (mach_task_self (), dev_master); + } if (!err) *devicePoly = MACH_MSG_TYPE_MOVE_SEND; } diff --git a/pci-arbiter/main.c b/pci-arbiter/main.c index 5e54b2f2..dadda0fb 100644 --- a/pci-arbiter/main.c +++ b/pci-arbiter/main.c @@ -80,6 +80,7 @@ pci_device_open (mach_port_t reply_port, mach_msg_type_name_t reply_port_type, if (dev_master == MACH_PORT_NULL) return D_NO_SUCH_DEVICE; err = device_open (dev_master, mode, name, devp); + mach_port_deallocate (mach_task_self (), dev_master); if (err) return err; *devicePoly = MACH_MSG_TYPE_MOVE_SEND; diff --git a/rumpdisk/block-rump.c b/rumpdisk/block-rump.c index 71435f20..309495dd 100644 --- a/rumpdisk/block-rump.c +++ b/rumpdisk/block-rump.c @@ -182,11 +182,14 @@ rumpdisk_device_init (void) { device_close (device); mach_port_deallocate (mach_task_self (), device); + mach_port_deallocate (mach_task_self (), device_master); fprintf(stderr, "Kernel is already driving a SATA device, skipping probing " RUMP_TYPE_STRING " disks\n"); fflush(stderr); disabled = 1; return; } + + mach_port_deallocate (mach_task_self (), device_master); } rump_init (); } |