- IopUnloadDriver: Only add the DOE_UNLOAD_PENDING to the Device's DeviceExtensions Flags and check for attached devices and reference counts if the DriverObject->DriverUnload is valid. Verified on XP.

- IopLoadUnloadDriver: Add a check to verify that ImagePath.Buffer is non null before freeing it. 

svn path=/trunk/; revision=41314
This commit is contained in:
Michael Martin 2009-06-07 01:18:15 +00:00
parent 1163e01722
commit fddbec411f

View file

@ -1083,6 +1083,13 @@ IopUnloadDriver(PUNICODE_STRING DriverServiceName, BOOLEAN UnloadPnpDrivers)
ExFreePool(ImagePath.Buffer);
/*
* Unload the module and release the references to the device object
*/
/* Call the load/unload routine, depending on current process */
if (DriverObject->DriverUnload && DriverObject->DriverSection)
{
/* Loop through each device object of the driver
and set DOE_UNLOAD_PENDING flag */
DeviceObject = DriverObject->DeviceObject;
@ -1111,14 +1118,6 @@ IopUnloadDriver(PUNICODE_STRING DriverServiceName, BOOLEAN UnloadPnpDrivers)
return STATUS_SUCCESS;
}
/*
* Unload the module and release the references to the device object
*/
/* Call the load/unload routine, depending on current process */
if (DriverObject->DriverUnload && DriverObject->DriverSection)
{
/* Set the unload invoked flag */
DriverObject->Flags |= DRVO_UNLOAD_INVOKED;
@ -1681,6 +1680,7 @@ IopLoadUnloadDriver(PLOAD_UNLOAD_PARAMS LoadParams)
if (!NT_SUCCESS(Status))
{
DPRINT("RtlQueryRegistryValues() failed (Status %lx)\n", Status);
if (ImagePath.Buffer)
ExFreePool(ImagePath.Buffer);
LoadParams->Status = Status;
(VOID)KeSetEvent(&LoadParams->Event, 0, FALSE);