From 99913119c19b2742242ecd6d5c4e69b7753b1126 Mon Sep 17 00:00:00 2001 From: Yuri Benditovich Date: Fri, 29 Nov 2024 13:32:27 +0200 Subject: [PATCH] netkvm: deregister miniport in erroneous path https://issues.redhat.com/browse/RHEL-68725 The problem can be reproduced under driver verifier with low resource simulation. If the miniport is registered but the protocol fail to register we need to deregister the miniport. Otherwise in future attempts to load the driver the NDIS enters erroneous state and may issue BSOD. Example of BSOD: BUGCODE_NDIS_DRIVER/NDIS_BUGCHECK_REFCOUNT_IMBALANCE. Signed-off-by: Yuri Benditovich --- NetKVM/wlh/ParaNdis6_Driver.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NetKVM/wlh/ParaNdis6_Driver.cpp b/NetKVM/wlh/ParaNdis6_Driver.cpp index 23533d4bd..849eb661b 100755 --- a/NetKVM/wlh/ParaNdis6_Driver.cpp +++ b/NetKVM/wlh/ParaNdis6_Driver.cpp @@ -1199,6 +1199,10 @@ NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING pRegistryPath else { DEBUG_EXIT_STATUS(0, status); + if (DriverHandle) + { + NdisMDeregisterMiniportDriver(DriverHandle); + } ParaNdis_DebugCleanup(pDriverObject); #ifdef NETKVM_WPP_ENABLED WPP_CLEANUP(pDriverObject);