mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
- Check if allocation of work item succeeded - Thanks Ged, aicom
- Fix leaking of a work item on close event / irp stream run out svn path=/trunk/; revision=40375
This commit is contained in:
parent
0ae0d6a95c
commit
a3e2c4bb4f
2 changed files with 45 additions and 21 deletions
|
@ -135,6 +135,13 @@ PcAddAdapterDevice(
|
|||
/* allocate create item */
|
||||
portcls_ext->CreateItems = AllocateItem(NonPagedPool, MaxObjects * sizeof(KSOBJECT_CREATE_ITEM), TAG_PORTCLASS);
|
||||
|
||||
if (!portcls_ext->CreateItems)
|
||||
{
|
||||
/* not enough resources */
|
||||
IoDeleteDevice(fdo);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
/* store the physical device object */
|
||||
portcls_ext->PhysicalDeviceObject = PhysicalDeviceObject;
|
||||
/* set up the start device function */
|
||||
|
@ -152,6 +159,17 @@ PcAddAdapterDevice(
|
|||
/* allocate work item */
|
||||
portcls_ext->WorkItem = IoAllocateWorkItem(fdo);
|
||||
|
||||
if (!portcls_ext->WorkItem)
|
||||
{
|
||||
/* not enough resources */
|
||||
FreeItem(portcls_ext->CreateItems, TAG_PORTCLASS);
|
||||
/* delete created fdo */
|
||||
IoDeleteDevice(fdo);
|
||||
/* return error code */
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
|
||||
/* allocate the device header */
|
||||
status = KsAllocateDeviceHeader(&portcls_ext->KsDeviceHeader, MaxObjects, portcls_ext->CreateItems);
|
||||
/* did we succeed */
|
||||
|
@ -159,6 +177,8 @@ PcAddAdapterDevice(
|
|||
{
|
||||
/* free previously allocated create items */
|
||||
FreeItem(portcls_ext->CreateItems, TAG_PORTCLASS);
|
||||
/* free allocated work item */
|
||||
IoFreeWorkItem(portcls_ext->WorkItem);
|
||||
/* delete created fdo */
|
||||
IoDeleteDevice(fdo);
|
||||
/* return error code */
|
||||
|
@ -180,6 +200,8 @@ PcAddAdapterDevice(
|
|||
KsFreeDeviceHeader(portcls_ext->KsDeviceHeader);
|
||||
/* free previously allocated create items */
|
||||
FreeItem(portcls_ext->CreateItems, TAG_PORTCLASS);
|
||||
/* free allocated work item */
|
||||
IoFreeWorkItem(portcls_ext->WorkItem);
|
||||
/* delete created fdo */
|
||||
IoDeleteDevice(fdo);
|
||||
/* return error code */
|
||||
|
|
|
@ -215,21 +215,21 @@ StopStreamRoutine(
|
|||
IN PVOID SystemArgument1,
|
||||
IN PVOID SystemArgument2)
|
||||
{
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
PPCLASS_DEVICE_EXTENSION DeviceExtension;
|
||||
IPortPinWaveCyclicImpl * This = (IPortPinWaveCyclicImpl*)DeferredContext;
|
||||
PIO_WORKITEM WorkItem;
|
||||
|
||||
if (This->IrpQueue->lpVtbl->NumMappings(This->IrpQueue))
|
||||
return;
|
||||
|
||||
WorkItem = IoAllocateWorkItem(GetDeviceObject(This->Port));
|
||||
if (!WorkItem)
|
||||
return;
|
||||
|
||||
IoQueueWorkItem(WorkItem, StopStreamWorkerRoutine, DelayedWorkQueue, (PVOID)This);
|
||||
/* Get device object */
|
||||
DeviceObject = GetDeviceObject(This->Port);
|
||||
/* Get device extension */
|
||||
DeviceExtension = (PPCLASS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
/* queue the work item */
|
||||
IoQueueWorkItem(DeviceExtension->WorkItem, StopStreamWorkerRoutine, DelayedWorkQueue, (PVOID)This);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static
|
||||
VOID
|
||||
NTAPI
|
||||
|
@ -249,7 +249,6 @@ IServiceSink_fnRequestService(
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
Status = This->Stream->lpVtbl->GetPosition(This->Stream, &Position);
|
||||
DPRINT("Position %u Buffer %p BufferSize %u ActiveIrpOffset %u\n", Position, Buffer, This->CommonBufferSize, BufferSize);
|
||||
|
||||
|
@ -692,23 +691,26 @@ IPortPinWaveCyclic_fnClose(
|
|||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
PIO_WORKITEM WorkItem;
|
||||
|
||||
PPCLASS_DEVICE_EXTENSION DeviceExtension;
|
||||
IPortPinWaveCyclicImpl * This = (IPortPinWaveCyclicImpl*)iface;
|
||||
|
||||
if (This->Stream)
|
||||
{
|
||||
WorkItem = IoAllocateWorkItem(DeviceObject);
|
||||
if (WorkItem)
|
||||
if (Irp)
|
||||
{
|
||||
if (Irp)
|
||||
{
|
||||
This->CloseIrp = Irp;
|
||||
IoMarkIrpPending(Irp);
|
||||
Irp->IoStatus.Information = 0;
|
||||
Irp->IoStatus.Status = STATUS_PENDING;
|
||||
}
|
||||
IoQueueWorkItem(WorkItem, CloseStreamRoutine, DelayedWorkQueue, (PVOID)This);
|
||||
This->CloseIrp = Irp;
|
||||
IoMarkIrpPending(Irp);
|
||||
Irp->IoStatus.Information = 0;
|
||||
Irp->IoStatus.Status = STATUS_PENDING;
|
||||
}
|
||||
/* Get device extension */
|
||||
DeviceExtension = (PPCLASS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
/* defer work item */
|
||||
IoQueueWorkItem(DeviceExtension->WorkItem, CloseStreamRoutine, DelayedWorkQueue, (PVOID)This);
|
||||
|
||||
if (Irp)
|
||||
{
|
||||
/* The WaveCyclic filter passes close request with NULL / IRP */
|
||||
return STATUS_PENDING;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue