https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0bdae2114aa2300cee183…
commit 0bdae2114aa2300cee18319752f0b6acc22d93d5
Author: George Bișoc <george.bisoc(a)reactos.org>
AuthorDate: Sat Dec 31 17:50:25 2022 +0100
Commit: George Bișoc <george.bisoc(a)reactos.org>
CommitDate: Tue Jan 3 16:48:03 2023 +0100
[NTOS:CM] Cleanup the hive in case linking it to master fails (#4969)
Currently the failure code path doesn't do any kind of cleanup against
the hive that was being linked to master. The cleanup is pretty
straightforward as you just simply close the hive file handles and free
the registry kernel structures.
CORE-5772
CORE-17263
CORE-13559
---
ntoskrnl/config/cmapi.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/ntoskrnl/config/cmapi.c b/ntoskrnl/config/cmapi.c
index 6555658435f..e21eea3b793 100644
--- a/ntoskrnl/config/cmapi.c
+++ b/ntoskrnl/config/cmapi.c
@@ -2121,18 +2121,24 @@ CmLoadKey(IN POBJECT_ATTRIBUTES TargetKey,
/* Release the hive */
CmHive->Hive.HiveFlags &= ~HIVE_IS_UNLOADING;
CmHive->CreatorOwner = NULL;
-
- /* Allow loads */
- ExReleasePushLock(&CmpLoadHiveLock);
}
else
{
DPRINT1("CmpLinkHiveToMaster failed, Status %lx\n", Status);
- /* FIXME: TODO */
- // ASSERT(FALSE); see CORE-17263
- ExReleasePushLock(&CmpLoadHiveLock);
+
+ /* We're touching this hive, set the loading flag */
+ CmHive->HiveIsLoading = TRUE;
+
+ /* Close associated file handles */
+ CmpCloseHiveFiles(CmHive);
+
+ /* Cleanup its resources */
+ CmpDestroyHive(CmHive);
}
+ /* Allow loads */
+ ExReleasePushLock(&CmpLoadHiveLock);
+
/* Is this first profile load? */
if (!CmpProfileLoaded && !CmpWasSetupBoot)
{