Skip to content

Commit

Permalink
fix mem leak in registry notify change handler (openzfs#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
datacore-rm authored and andrewc12 committed Sep 23, 2022
1 parent 8c58db3 commit 2e18a9e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions module/os/windows/zfs/sysctl_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,16 @@ sysctl_os_registry_change(PVOID Parameter)
if (registry_notify_fd == 0) {

registry_notify_fd = sysctl_os_open_registry(RegistryPath);
RtlDuplicateUnicodeString(
RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING | RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
RegistryPath,
&sysctl_os_RegistryPath);
ExInitializeWorkItem(&wqi, sysctl_os_registry_change, &sysctl_os_RegistryPath);

if (registry_notify_fd != 0) {
RtlDuplicateUnicodeString(
RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING |
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
RegistryPath,
&sysctl_os_RegistryPath);
ExInitializeWorkItem(&wqi, sysctl_os_registry_change,
&sysctl_os_RegistryPath);
}
} else {
// Notified, re-scan registry
sysctl_os_init(RegistryPath);
Expand Down Expand Up @@ -391,9 +395,10 @@ sysctl_os_fini(void)
{
HANDLE fd = registry_notify_fd;
registry_notify_fd = 0;
RtlFreeUnicodeString(&sysctl_os_RegistryPath);

if (fd != 0)
ZwClose(fd);
RtlFreeUnicodeString(&sysctl_os_RegistryPath);
}

int
Expand Down

0 comments on commit 2e18a9e

Please sign in to comment.