From 1572bfd989e60555e91f9c82e797c83798a0b15d Mon Sep 17 00:00:00 2001 From: TuxSH Date: Wed, 27 Dec 2017 19:30:57 +0100 Subject: [PATCH] [sm] Fix process unregistering logic bug (fixes #984) In this case pm+sm were supposed to automatically unregister ro's services (the kernel can close a dying process's handle automatically). Not doing this apparently induced a reference leak of DevMenu's as a process, preventing it to be destroyed and the memory allocation reslimit counter to be updated by KProcess's destructor accordingly. --- sysmodules/sm/source/processes.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sysmodules/sm/source/processes.c b/sysmodules/sm/source/processes.c index b4f7236..5977e98 100644 --- a/sysmodules/sm/source/processes.c +++ b/sysmodules/sm/source/processes.c @@ -58,13 +58,16 @@ Result UnregisterProcess(u32 pid) svcCloseHandle(processData->notificationSemaphore); // Unregister the services registered by the process - for(u32 i = 0; i < nbServices; i++) + u32 i = 0; + while(i < nbServices) { if(servicesInfo[i].pid == pid) { svcCloseHandle(servicesInfo[i].clientPort); servicesInfo[i] = servicesInfo[--nbServices]; } + else + ++i; } moveNode(processData, &freeProcessDataList, false);