aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services
diff options
context:
space:
mode:
authorMary <me@thog.eu>2020-12-03 19:19:10 +0100
committerGitHub <noreply@github.com>2020-12-03 19:19:10 +0100
commit0ab1c42eeae48530853ec22a8790a492c254006d (patch)
treea091e902664bd2df193d2f79d10f4cfff3bd0e87 /Ryujinx.HLE/HOS/Services
parent1b053d2222c5c3f9b649e0fcf423457aa705ca34 (diff)
Make sure to not leak copy handles passed in request (#1772)
* Make sure to not leak copy handles passed in request Following last gdkchan's PR this make sure to close copy handles that are passed by guest when it should. * fix comment copy pasta
Diffstat (limited to 'Ryujinx.HLE/HOS/Services')
-rw-r--r--Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs24
-rw-r--r--Ryujinx.HLE/HOS/Services/Audio/IAudioOutManager.cs2
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs7
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvDeviceFile.cs5
4 files changed, 23 insertions, 15 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs b/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs
index 86e5566a..c941cf4f 100644
--- a/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs
+++ b/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs
@@ -1,6 +1,7 @@
using Ryujinx.Audio;
using Ryujinx.Cpu;
using Ryujinx.HLE.HOS.Ipc;
+using Ryujinx.HLE.HOS.Kernel;
using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Kernel.Threading;
using System;
@@ -10,18 +11,20 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioOutManager
{
class IAudioOut : IpcService, IDisposable
{
- private readonly IAalOutput _audioOut;
- private readonly KEvent _releaseEvent;
- private int _releaseEventHandle;
- private readonly int _track;
- private readonly int _clientHandle;
+ private readonly KernelContext _kernelContext;
+ private readonly IAalOutput _audioOut;
+ private readonly KEvent _releaseEvent;
+ private int _releaseEventHandle;
+ private readonly int _track;
+ private readonly int _clientHandle;
- public IAudioOut(IAalOutput audioOut, KEvent releaseEvent, int track, int clientHandle)
+ public IAudioOut(KernelContext kernelContext, IAalOutput audioOut, KEvent releaseEvent, int track, int clientHandle)
{
- _audioOut = audioOut;
- _releaseEvent = releaseEvent;
- _track = track;
- _clientHandle = clientHandle;
+ _kernelContext = kernelContext;
+ _audioOut = audioOut;
+ _releaseEvent = releaseEvent;
+ _track = track;
+ _clientHandle = clientHandle;
}
[Command(0)]
@@ -217,6 +220,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioOutManager
{
if (disposing)
{
+ _kernelContext.Syscall.CloseHandle(_clientHandle);
_audioOut.CloseTrack(_track);
}
}
diff --git a/Ryujinx.HLE/HOS/Services/Audio/IAudioOutManager.cs b/Ryujinx.HLE/HOS/Services/Audio/IAudioOutManager.cs
index 908bf14e..6204a7be 100644
--- a/Ryujinx.HLE/HOS/Services/Audio/IAudioOutManager.cs
+++ b/Ryujinx.HLE/HOS/Services/Audio/IAudioOutManager.cs
@@ -134,7 +134,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio
int track = audioOut.OpenTrack(sampleRate, channels, callback);
- MakeObject(context, new IAudioOut(audioOut, releaseEvent, track, context.Request.HandleDesc.ToCopy[0]));
+ MakeObject(context, new IAudioOut(context.Device.System.KernelContext, audioOut, releaseEvent, track, context.Request.HandleDesc.ToCopy[0]));
context.ResponseData.Write(sampleRate);
context.ResponseData.Write(channels);
diff --git a/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs b/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs
index 52fe3ea1..8b1deb97 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs
@@ -329,6 +329,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv
context.ResponseData.Write((uint)NvResult.Success);
+ // Close transfer memory immediately as we don't use it.
+ context.Device.System.KernelContext.Syscall.CloseHandle(transferMemHandle);
+
return ResultCode.Success;
}
@@ -384,9 +387,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
if (errorCode == NvResult.Success)
{
- KSharedMemory sharedMemory = context.Process.HandleTable.GetObject<KSharedMemory>(sharedMemoryHandle);
-
- errorCode = ConvertInternalErrorCode(deviceFile.MapSharedMemory(sharedMemory, argument));
+ errorCode = ConvertInternalErrorCode(deviceFile.MapSharedMemory(sharedMemoryHandle, argument));
}
}
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvDeviceFile.cs b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvDeviceFile.cs
index 34ff4ccb..f143f6d1 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvDeviceFile.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvDeviceFile.cs
@@ -28,8 +28,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices
return NvInternalResult.NotImplemented;
}
- public virtual NvInternalResult MapSharedMemory(KSharedMemory sharedMemory, uint argument)
+ public virtual NvInternalResult MapSharedMemory(int sharedMemoryHandle, uint argument)
{
+ // Close shared memory immediately as we don't use it.
+ Context.Device.System.KernelContext.Syscall.CloseHandle(sharedMemoryHandle);
+
return NvInternalResult.NotImplemented;
}