From 49c4c329f6c873bcf8da22c8da08a704a563ba4e Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 10 May 2021 16:12:01 -0700 Subject: hle: service: sm: GetService: Reserve session resource when we create a KSession. --- src/core/hle/service/sm/sm.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index 7bd571880..726bef4c3 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -133,9 +133,16 @@ void SM::GetService(Kernel::HLERequestContext& ctx) { auto* port = result.Unwrap(); + Kernel::KScopedResourceReservation session_reservation( + kernel.CurrentProcess()->GetResourceLimit(), Kernel::LimitableResource::Sessions); + R_UNLESS(session_reservation.Succeeded(), Kernel::ResultLimitReached); + auto* session = Kernel::KSession::Create(kernel); session->Initialize(&port->GetClientPort(), std::move(name)); + // Commit the session reservation. + session_reservation.Commit(); + if (port->GetServerPort().GetHLEHandler()) { port->GetServerPort().GetHLEHandler()->ClientConnected(&session->GetServerSession()); } else { -- cgit v1.2.3