[NTOSKNRL]

Add a missing NULL check in IoShutdownSystem

svn path=/trunk/; revision=56939
This commit is contained in:
Timo Kreuzer 2012-07-22 18:48:09 +00:00
parent dd12f74611
commit 189a83fdde

View file

@ -136,10 +136,10 @@ IoShutdownSystem(IN ULONG Phase)
PIRP Irp; PIRP Irp;
KEVENT Event; KEVENT Event;
NTSTATUS Status; NTSTATUS Status;
/* Initialize an event to wait on */ /* Initialize an event to wait on */
KeInitializeEvent(&Event, NotificationEvent, FALSE); KeInitializeEvent(&Event, NotificationEvent, FALSE);
/* What phase? */ /* What phase? */
if (Phase == 0) if (Phase == 0)
{ {
@ -167,11 +167,14 @@ IoShutdownSystem(IN ULONG Phase)
NULL, NULL,
&Event, &Event,
&StatusBlock); &StatusBlock);
Status = IoCallDriver(DeviceObject, Irp); if (Irp)
if (Status == STATUS_PENDING)
{ {
/* Wait on the driver */ Status = IoCallDriver(DeviceObject, Irp);
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); if (Status == STATUS_PENDING)
{
/* Wait on the driver */
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
}
} }
/* Remove the flag */ /* Remove the flag */
@ -202,7 +205,7 @@ IoShutdownSystem(IN ULONG Phase)
/* Shutdown tape filesystems */ /* Shutdown tape filesystems */
IopShutdownBaseFileSystems(&IopTapeFileSystemQueueHead); IopShutdownBaseFileSystems(&IopTapeFileSystemQueueHead);
/* Loop last-chance shutdown notifications */ /* Loop last-chance shutdown notifications */
ListEntry = ExInterlockedRemoveHeadList(&LastChanceShutdownListHead, ListEntry = ExInterlockedRemoveHeadList(&LastChanceShutdownListHead,
&ShutdownListLock); &ShutdownListLock);
@ -889,7 +892,7 @@ IoCreateDevice(IN PDRIVER_OBJECT DriverObject,
/* Set the Type and Size. Question: why is Size 0 on Windows? */ /* Set the Type and Size. Question: why is Size 0 on Windows? */
DeviceObjectExtension->Type = IO_TYPE_DEVICE_OBJECT_EXTENSION; DeviceObjectExtension->Type = IO_TYPE_DEVICE_OBJECT_EXTENSION;
DeviceObjectExtension->Size = 0; DeviceObjectExtension->Size = 0;
/* Initialize with Power Manager */ /* Initialize with Power Manager */
PoInitializeDeviceObject(DeviceObjectExtension); PoInitializeDeviceObject(DeviceObjectExtension);
@ -981,7 +984,7 @@ IoCreateDevice(IN PDRIVER_OBJECT DriverObject,
ASSERT((DriverObject->Flags & DRVO_UNLOAD_INVOKED) == 0); ASSERT((DriverObject->Flags & DRVO_UNLOAD_INVOKED) == 0);
CreatedDeviceObject->DriverObject = DriverObject; CreatedDeviceObject->DriverObject = DriverObject;
IopEditDeviceList(DriverObject, CreatedDeviceObject, IopAdd); IopEditDeviceList(DriverObject, CreatedDeviceObject, IopAdd);
/* Link with the power manager */ /* Link with the power manager */
if (CreatedDeviceObject->Vpb) PoVolumeDevice(CreatedDeviceObject); if (CreatedDeviceObject->Vpb) PoVolumeDevice(CreatedDeviceObject);
@ -1402,7 +1405,7 @@ IoRegisterLastChanceShutdownNotification(IN PDEVICE_OBJECT DeviceObject)
/* Set the DO */ /* Set the DO */
Entry->DeviceObject = DeviceObject; Entry->DeviceObject = DeviceObject;
/* Reference it so it doesn't go away */ /* Reference it so it doesn't go away */
ObReferenceObject(DeviceObject); ObReferenceObject(DeviceObject);
@ -1433,7 +1436,7 @@ IoRegisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
/* Set the DO */ /* Set the DO */
Entry->DeviceObject = DeviceObject; Entry->DeviceObject = DeviceObject;
/* Reference it so it doesn't go away */ /* Reference it so it doesn't go away */
ObReferenceObject(DeviceObject); ObReferenceObject(DeviceObject);
@ -1457,7 +1460,7 @@ IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
PSHUTDOWN_ENTRY ShutdownEntry; PSHUTDOWN_ENTRY ShutdownEntry;
PLIST_ENTRY NextEntry; PLIST_ENTRY NextEntry;
KIRQL OldIrql; KIRQL OldIrql;
/* Remove the flag */ /* Remove the flag */
DeviceObject->Flags &= ~DO_SHUTDOWN_REGISTERED; DeviceObject->Flags &= ~DO_SHUTDOWN_REGISTERED;
@ -1480,7 +1483,7 @@ IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
/* Free the entry */ /* Free the entry */
ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY); ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY);
/* Get rid of our reference to it */ /* Get rid of our reference to it */
ObDereferenceObject(DeviceObject); ObDereferenceObject(DeviceObject);
} }
@ -1507,7 +1510,7 @@ IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
/* Free the entry */ /* Free the entry */
ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY); ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY);
/* Get rid of our reference to it */ /* Get rid of our reference to it */
ObDereferenceObject(DeviceObject); ObDereferenceObject(DeviceObject);
} }