[WIN32SS:ENG] Do not free LDEV if unloading a driver failed

Currently, LDEVOBJ_bUnloadImage always returns FALSE due to missing functionality in ntoskrnl.
LDEVOBJ_vFreeLDEV contains an assert that driver is correctly unloaded before freeing it.
Prevent this assert by calling LDEVOBJ_vFreeLDEV only if LDEVOBJ_bUnloadImage succeed.

This can be easily triggered if DrvEnableDriver function (called in LDEVOBJ_bEnableDriver) fails.
This commit is contained in:
Hervé Poussineau 2023-04-16 18:48:15 +02:00
parent 7d71456144
commit 49246541de

View file

@ -442,8 +442,10 @@ LDEVOBJ_pLoadDriver(
ERR("LDEVOBJ_bEnableDriver failed\n");
/* Unload the image. */
LDEVOBJ_bUnloadImage(pldev);
LDEVOBJ_vFreeLDEV(pldev);
if (LDEVOBJ_bUnloadImage(pldev))
LDEVOBJ_vFreeLDEV(pldev);
else
ERR("Could not unload driver. Leaking memory\n");
pldev = NULL;
goto leave;
}