mirror of
https://github.com/reactos/reactos.git
synced 2025-04-30 19:19:00 +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 */
|
/* allocate create item */
|
||||||
portcls_ext->CreateItems = AllocateItem(NonPagedPool, MaxObjects * sizeof(KSOBJECT_CREATE_ITEM), TAG_PORTCLASS);
|
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 */
|
/* store the physical device object */
|
||||||
portcls_ext->PhysicalDeviceObject = PhysicalDeviceObject;
|
portcls_ext->PhysicalDeviceObject = PhysicalDeviceObject;
|
||||||
/* set up the start device function */
|
/* set up the start device function */
|
||||||
|
@ -152,6 +159,17 @@ PcAddAdapterDevice(
|
||||||
/* allocate work item */
|
/* allocate work item */
|
||||||
portcls_ext->WorkItem = IoAllocateWorkItem(fdo);
|
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 */
|
/* allocate the device header */
|
||||||
status = KsAllocateDeviceHeader(&portcls_ext->KsDeviceHeader, MaxObjects, portcls_ext->CreateItems);
|
status = KsAllocateDeviceHeader(&portcls_ext->KsDeviceHeader, MaxObjects, portcls_ext->CreateItems);
|
||||||
/* did we succeed */
|
/* did we succeed */
|
||||||
|
@ -159,6 +177,8 @@ PcAddAdapterDevice(
|
||||||
{
|
{
|
||||||
/* free previously allocated create items */
|
/* free previously allocated create items */
|
||||||
FreeItem(portcls_ext->CreateItems, TAG_PORTCLASS);
|
FreeItem(portcls_ext->CreateItems, TAG_PORTCLASS);
|
||||||
|
/* free allocated work item */
|
||||||
|
IoFreeWorkItem(portcls_ext->WorkItem);
|
||||||
/* delete created fdo */
|
/* delete created fdo */
|
||||||
IoDeleteDevice(fdo);
|
IoDeleteDevice(fdo);
|
||||||
/* return error code */
|
/* return error code */
|
||||||
|
@ -180,6 +200,8 @@ PcAddAdapterDevice(
|
||||||
KsFreeDeviceHeader(portcls_ext->KsDeviceHeader);
|
KsFreeDeviceHeader(portcls_ext->KsDeviceHeader);
|
||||||
/* free previously allocated create items */
|
/* free previously allocated create items */
|
||||||
FreeItem(portcls_ext->CreateItems, TAG_PORTCLASS);
|
FreeItem(portcls_ext->CreateItems, TAG_PORTCLASS);
|
||||||
|
/* free allocated work item */
|
||||||
|
IoFreeWorkItem(portcls_ext->WorkItem);
|
||||||
/* delete created fdo */
|
/* delete created fdo */
|
||||||
IoDeleteDevice(fdo);
|
IoDeleteDevice(fdo);
|
||||||
/* return error code */
|
/* return error code */
|
||||||
|
|
|
@ -215,21 +215,21 @@ StopStreamRoutine(
|
||||||
IN PVOID SystemArgument1,
|
IN PVOID SystemArgument1,
|
||||||
IN PVOID SystemArgument2)
|
IN PVOID SystemArgument2)
|
||||||
{
|
{
|
||||||
|
PDEVICE_OBJECT DeviceObject;
|
||||||
|
PPCLASS_DEVICE_EXTENSION DeviceExtension;
|
||||||
IPortPinWaveCyclicImpl * This = (IPortPinWaveCyclicImpl*)DeferredContext;
|
IPortPinWaveCyclicImpl * This = (IPortPinWaveCyclicImpl*)DeferredContext;
|
||||||
PIO_WORKITEM WorkItem;
|
|
||||||
|
|
||||||
if (This->IrpQueue->lpVtbl->NumMappings(This->IrpQueue))
|
if (This->IrpQueue->lpVtbl->NumMappings(This->IrpQueue))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
WorkItem = IoAllocateWorkItem(GetDeviceObject(This->Port));
|
/* Get device object */
|
||||||
if (!WorkItem)
|
DeviceObject = GetDeviceObject(This->Port);
|
||||||
return;
|
/* Get device extension */
|
||||||
|
DeviceExtension = (PPCLASS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||||
IoQueueWorkItem(WorkItem, StopStreamWorkerRoutine, DelayedWorkQueue, (PVOID)This);
|
/* queue the work item */
|
||||||
|
IoQueueWorkItem(DeviceExtension->WorkItem, StopStreamWorkerRoutine, DelayedWorkQueue, (PVOID)This);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
|
@ -249,7 +249,6 @@ IServiceSink_fnRequestService(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Status = This->Stream->lpVtbl->GetPosition(This->Stream, &Position);
|
Status = This->Stream->lpVtbl->GetPosition(This->Stream, &Position);
|
||||||
DPRINT("Position %u Buffer %p BufferSize %u ActiveIrpOffset %u\n", Position, Buffer, This->CommonBufferSize, BufferSize);
|
DPRINT("Position %u Buffer %p BufferSize %u ActiveIrpOffset %u\n", Position, Buffer, This->CommonBufferSize, BufferSize);
|
||||||
|
|
||||||
|
@ -692,14 +691,10 @@ IPortPinWaveCyclic_fnClose(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
PIO_WORKITEM WorkItem;
|
PPCLASS_DEVICE_EXTENSION DeviceExtension;
|
||||||
|
|
||||||
IPortPinWaveCyclicImpl * This = (IPortPinWaveCyclicImpl*)iface;
|
IPortPinWaveCyclicImpl * This = (IPortPinWaveCyclicImpl*)iface;
|
||||||
|
|
||||||
if (This->Stream)
|
if (This->Stream)
|
||||||
{
|
|
||||||
WorkItem = IoAllocateWorkItem(DeviceObject);
|
|
||||||
if (WorkItem)
|
|
||||||
{
|
{
|
||||||
if (Irp)
|
if (Irp)
|
||||||
{
|
{
|
||||||
|
@ -708,7 +703,14 @@ IPortPinWaveCyclic_fnClose(
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
Irp->IoStatus.Status = STATUS_PENDING;
|
Irp->IoStatus.Status = STATUS_PENDING;
|
||||||
}
|
}
|
||||||
IoQueueWorkItem(WorkItem, CloseStreamRoutine, DelayedWorkQueue, (PVOID)This);
|
/* 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;
|
return STATUS_PENDING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue