Author: janderwald
Date: Sun Apr 5 20:39:51 2009
New Revision: 40375
URL:
http://svn.reactos.org/svn/reactos?rev=40375&view=rev
Log:
- Check if allocation of work item succeeded - Thanks Ged, aicom
- Fix leaking of a work item on close event / irp stream run out
Modified:
trunk/reactos/drivers/wdm/audio/backpln/portcls/adapter.c
trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/adapter.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/adapter.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/adapter.c [iso-8859-1] Sun Apr 5
20:39:51 2009
@@ -135,6 +135,13 @@
/* 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 @@
/* 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 @@
{
/* 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 @@
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 */
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c [iso-8859-1]
(original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c [iso-8859-1] Sun Apr
5 20:39:51 2009
@@ -215,20 +215,20 @@
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
@@ -248,7 +248,6 @@
KeInsertQueueDpc(&This->Dpc, NULL, NULL);
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 @@
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;
}
}