From 39affd9197404fb7d54f97039867379db0fdb549 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Sun, 19 Apr 2009 22:01:57 +0000 Subject: [PATCH] - Silence a few debug prints - Fix memory leaks on failure svn path=/trunk/; revision=40596 --- reactos/drivers/wdm/audio/sysaudio/control.c | 4 +-- reactos/drivers/wdm/audio/sysaudio/deviface.c | 34 ++++++++++++------- .../drivers/wdm/audio/sysaudio/dispatcher.c | 14 ++++---- reactos/drivers/wdm/audio/sysaudio/main.c | 6 ++-- reactos/drivers/wdm/audio/sysaudio/pin.c | 12 +++---- 5 files changed, 40 insertions(+), 30 deletions(-) diff --git a/reactos/drivers/wdm/audio/sysaudio/control.c b/reactos/drivers/wdm/audio/sysaudio/control.c index 151740dcdb6..795cee81f4a 100644 --- a/reactos/drivers/wdm/audio/sysaudio/control.c +++ b/reactos/drivers/wdm/audio/sysaudio/control.c @@ -122,7 +122,7 @@ SetMixerInputOutputFormat( /* set the input format */ PinRequest.PinId = 0; - //DPRINT1("InputFormat %p Size %u WaveFormatSize %u DataFormat %u WaveEx %u\n", InputFormat, InputFormat->FormatSize, sizeof(KSDATAFORMAT_WAVEFORMATEX), sizeof(KSDATAFORMAT), sizeof(WAVEFORMATEX)); + DPRINT("InputFormat %p Size %u WaveFormatSize %u DataFormat %u WaveEx %u\n", InputFormat, InputFormat->FormatSize, sizeof(KSDATAFORMAT_WAVEFORMATEX), sizeof(KSDATAFORMAT), sizeof(WAVEFORMATEX)); Status = KsSynchronousIoControlDevice(FileObject, KernelMode, IOCTL_KS_PROPERTY, (PVOID)&PinRequest, sizeof(KSP_PIN), @@ -134,7 +134,7 @@ SetMixerInputOutputFormat( /* set the the output format */ PinRequest.PinId = 1; - //DPRINT1("OutputFormat %p Size %u WaveFormatSize %u DataFormat %u WaveEx %u\n", OutputFormat, OutputFormat->FormatSize, sizeof(KSDATAFORMAT_WAVEFORMATEX), sizeof(KSDATAFORMAT), sizeof(WAVEFORMATEX)); + DPRINT("OutputFormat %p Size %u WaveFormatSize %u DataFormat %u WaveEx %u\n", OutputFormat, OutputFormat->FormatSize, sizeof(KSDATAFORMAT_WAVEFORMATEX), sizeof(KSDATAFORMAT), sizeof(WAVEFORMATEX)); Status = KsSynchronousIoControlDevice(FileObject, KernelMode, IOCTL_KS_PROPERTY, (PVOID)&PinRequest, sizeof(KSP_PIN), diff --git a/reactos/drivers/wdm/audio/sysaudio/deviface.c b/reactos/drivers/wdm/audio/sysaudio/deviface.c index 5ebaf6bd7f8..db43df5a81a 100644 --- a/reactos/drivers/wdm/audio/sysaudio/deviface.c +++ b/reactos/drivers/wdm/audio/sysaudio/deviface.c @@ -41,12 +41,18 @@ FilterPinWorkerRoutine( Status = KsSynchronousIoControlDevice(DeviceEntry->FileObject, KernelMode, IOCTL_KS_PROPERTY, (PVOID)&PropertyRequest, sizeof(KSPROPERTY), (PVOID)&Count, sizeof(ULONG), &BytesReturned); if (!NT_SUCCESS(Status)) { + ObDereferenceObject(DeviceEntry->FileObject); + ZwClose(DeviceEntry->Handle); + ExFreePool(DeviceEntry->DeviceName.Buffer); ExFreePool(DeviceEntry); return; } if (!Count) { + ObDereferenceObject(DeviceEntry->FileObject); + ZwClose(DeviceEntry->Handle); + ExFreePool(DeviceEntry->DeviceName.Buffer); ExFreePool(DeviceEntry); return; } @@ -56,6 +62,9 @@ FilterPinWorkerRoutine( if (!DeviceEntry->Pins) { /* no memory */ + ObDereferenceObject(DeviceEntry->FileObject); + ZwClose(DeviceEntry->Handle); + ExFreePool(DeviceEntry->DeviceName.Buffer); ExFreePool(DeviceEntry); return; } @@ -101,7 +110,7 @@ FilterPinWorkerRoutine( } - DPRINT1("Num Pins %u Num WaveIn Pins %u Name WaveOut Pins %u\n", DeviceEntry->NumberOfPins, DeviceEntry->NumWaveInPin, DeviceEntry->NumWaveOutPin); + DPRINT("Num Pins %u Num WaveIn Pins %u Name WaveOut Pins %u\n", DeviceEntry->NumberOfPins, DeviceEntry->NumWaveInPin, DeviceEntry->NumWaveOutPin); DeviceExtension = (PSYSAUDIODEVEXT)DeviceObject->DeviceExtension; @@ -139,7 +148,7 @@ OpenDevice( if (!NT_SUCCESS(Status)) { - DPRINT1("ZwCreateFile failed with %x\n", Status); + DPRINT("ZwCreateFile failed with %x\n", Status); return Status; } @@ -147,7 +156,7 @@ OpenDevice( if (!NT_SUCCESS(Status)) { ZwClose(NodeHandle); - DPRINT1("ObReferenceObjectByHandle failed with %x\n", Status); + DPRINT("ObReferenceObjectByHandle failed with %x\n", Status); return Status; } @@ -210,12 +219,13 @@ DeviceInterfaceChangeCallback( Status = OpenDevice(&DeviceEntry->DeviceName, &DeviceEntry->Handle, &DeviceEntry->FileObject); if (!NT_SUCCESS(Status)) { - DPRINT1("ZwCreateFile failed with %x\n", Status); + DPRINT("ZwCreateFile failed with %x\n", Status); + ExFreePool(DeviceEntry->DeviceName.Buffer); ExFreePool(DeviceEntry); return Status; } - DPRINT1("Successfully opened audio device %u handle %p file object %p device object %p\n", DeviceExtension->NumberOfKsAudioDevices, DeviceEntry->Handle, DeviceEntry->FileObject, DeviceEntry->FileObject->DeviceObject); + DPRINT("Successfully opened audio device %u handle %p file object %p device object %p\n", DeviceExtension->NumberOfKsAudioDevices, DeviceEntry->Handle, DeviceEntry->FileObject, DeviceEntry->FileObject->DeviceObject); //FIXME // mutal exclusion @@ -224,7 +234,7 @@ DeviceInterfaceChangeCallback( } else { - DPRINT1("Remove interface to audio device!\n"); + DPRINT("Remove interface to audio device!\n"); UNIMPLEMENTED return STATUS_SUCCESS; } @@ -250,7 +260,7 @@ SysAudioRegisterNotifications( if (!NT_SUCCESS(Status)) { - DPRINT1("IoRegisterPlugPlayNotification failed with %x\n", Status); + DPRINT("IoRegisterPlugPlayNotification failed with %x\n", Status); } Status = IoRegisterPlugPlayNotification(EventCategoryDeviceInterfaceChange, @@ -264,7 +274,7 @@ SysAudioRegisterNotifications( if (!NT_SUCCESS(Status)) { /* ignore failure for now */ - DPRINT1("IoRegisterPlugPlayNotification failed for DMOCATEGORY_ACOUSTIC_ECHO_CANCEL\n", Status); + DPRINT("IoRegisterPlugPlayNotification failed for DMOCATEGORY_ACOUSTIC_ECHO_CANCEL\n", Status); } return STATUS_SUCCESS; @@ -287,7 +297,7 @@ SysAudioRegisterDeviceInterfaces( } else { - DPRINT1("Failed to register KSCATEGORY_PREFERRED_MIDIOUT_DEVICE interface Status %x\n", Status); + DPRINT("Failed to register KSCATEGORY_PREFERRED_MIDIOUT_DEVICE interface Status %x\n", Status); return Status; } @@ -299,7 +309,7 @@ SysAudioRegisterDeviceInterfaces( } else { - DPRINT1("Failed to register KSCATEGORY_PREFERRED_WAVEIN_DEVICE interface Status %x\n", Status); + DPRINT("Failed to register KSCATEGORY_PREFERRED_WAVEIN_DEVICE interface Status %x\n", Status); return Status; } @@ -311,7 +321,7 @@ SysAudioRegisterDeviceInterfaces( } else { - DPRINT1("Failed to register KSCATEGORY_PREFERRED_WAVEOUT_DEVICE interface Status %x\n", Status); + DPRINT("Failed to register KSCATEGORY_PREFERRED_WAVEOUT_DEVICE interface Status %x\n", Status); } Status = IoRegisterDeviceInterface(DeviceObject, &KSCATEGORY_SYSAUDIO, NULL, &SymbolicLink); @@ -322,7 +332,7 @@ SysAudioRegisterDeviceInterfaces( } else { - DPRINT1("Failed to register KSCATEGORY_SYSAUDIO interface Status %x\n", Status); + DPRINT("Failed to register KSCATEGORY_SYSAUDIO interface Status %x\n", Status); } return Status; diff --git a/reactos/drivers/wdm/audio/sysaudio/dispatcher.c b/reactos/drivers/wdm/audio/sysaudio/dispatcher.c index fb7700a683c..005d319c071 100644 --- a/reactos/drivers/wdm/audio/sysaudio/dispatcher.c +++ b/reactos/drivers/wdm/audio/sysaudio/dispatcher.c @@ -128,7 +128,7 @@ Dispatch_fnClose( ExFreePool(DispatchContext); - //DPRINT1("Index %u DeviceIndex %u Pin %u References %u\n", Index, Client->Devs[Index].DeviceId, SubIndex, Entry->Pins[Client->Devs[Index].ClientHandles[SubIndex].PinId].References); + DPRINT("Index %u DeviceIndex %u Pin %u References %u\n", Index, Client->Devs[Index].DeviceId, SubIndex, Entry->Pins[Client->Devs[Index].ClientHandles[SubIndex].PinId].References); if (!Entry->Pins[Client->Devs[Index].ClientHandles[SubIndex].PinId].References) { DPRINT("Closing pin %p\n", Entry->Pins[Client->Devs[Index].ClientHandles[SubIndex].PinId].PinHandle); @@ -159,7 +159,7 @@ Dispatch_fnQuerySecurity( PDEVICE_OBJECT DeviceObject, PIRP Irp) { - DPRINT1("Dispatch_fnQuerySecurity called DeviceObject %p Irp %p\n", DeviceObject); + DPRINT("Dispatch_fnQuerySecurity called DeviceObject %p Irp %p\n", DeviceObject); Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; Irp->IoStatus.Information = 0; @@ -174,7 +174,7 @@ Dispatch_fnSetSecurity( PIRP Irp) { - DPRINT1("Dispatch_fnSetSecurity called DeviceObject %p Irp %p\n", DeviceObject); + DPRINT("Dispatch_fnSetSecurity called DeviceObject %p Irp %p\n", DeviceObject); Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; Irp->IoStatus.Information = 0; @@ -195,7 +195,7 @@ Dispatch_fnFastDeviceIoControl( PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject) { - DPRINT1("Dispatch_fnFastDeviceIoControl called DeviceObject %p Irp %p\n", DeviceObject); + DPRINT("Dispatch_fnFastDeviceIoControl called DeviceObject %p Irp %p\n", DeviceObject); return FALSE; @@ -214,7 +214,7 @@ Dispatch_fnFastRead( PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject) { - DPRINT1("Dispatch_fnFastRead called DeviceObject %p Irp %p\n", DeviceObject); + DPRINT("Dispatch_fnFastRead called DeviceObject %p Irp %p\n", DeviceObject); return FALSE; @@ -232,7 +232,7 @@ Dispatch_fnFastWrite( PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject) { - DPRINT1("Dispatch_fnFastWrite called DeviceObject %p Irp %p\n", DeviceObject); + DPRINT("Dispatch_fnFastWrite called DeviceObject %p Irp %p\n", DeviceObject); return FALSE; } @@ -353,7 +353,7 @@ DispatchCreateSysAudio( /* allocate object header */ Status = KsAllocateObjectHeader(&ObjectHeader, 1, CreateItem, Irp, &DispatchTable); - DPRINT1("KsAllocateObjectHeader result %x\n", Status); + DPRINT("KsAllocateObjectHeader result %x\n", Status); /* complete the irp */ Irp->IoStatus.Information = 0; Irp->IoStatus.Status = Status; diff --git a/reactos/drivers/wdm/audio/sysaudio/main.c b/reactos/drivers/wdm/audio/sysaudio/main.c index 93d3098319e..0b9d92d86b4 100644 --- a/reactos/drivers/wdm/audio/sysaudio/main.c +++ b/reactos/drivers/wdm/audio/sysaudio/main.c @@ -24,7 +24,7 @@ VOID NTAPI SysAudio_Unload(IN PDRIVER_OBJECT DriverObject) { - DPRINT1("SysAudio_Unload called\n"); + DPRINT("SysAudio_Unload called\n"); } NTSTATUS @@ -79,7 +79,7 @@ SysAudio_InstallDevice( SYSAUDIODEVEXT *DeviceExtension; - DPRINT1("SysAudio_InstallDevice called\n"); + DPRINT("SysAudio_InstallDevice called\n"); /* Create the device */ Status = IoCreateDevice(DriverObject, @@ -191,7 +191,7 @@ DriverEntry( IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath) { - DPRINT1("System audio graph builder (sysaudio) started\n"); + DPRINT("System audio graph builder (sysaudio) started\n"); /* Let ks handle these */ KsSetMajorFunctionHandler(DriverObject, IRP_MJ_CREATE); diff --git a/reactos/drivers/wdm/audio/sysaudio/pin.c b/reactos/drivers/wdm/audio/sysaudio/pin.c index 8a46221a9e2..5127b9c3d5a 100644 --- a/reactos/drivers/wdm/audio/sysaudio/pin.c +++ b/reactos/drivers/wdm/audio/sysaudio/pin.c @@ -206,7 +206,7 @@ Pin_fnClose( PDEVICE_OBJECT DeviceObject, PIRP Irp) { - DPRINT1("Pin_fnClose called DeviceObject %p Irp %p\n", DeviceObject); + DPRINT("Pin_fnClose called DeviceObject %p Irp %p\n", DeviceObject); Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = 0; @@ -220,7 +220,7 @@ Pin_fnQuerySecurity( PDEVICE_OBJECT DeviceObject, PIRP Irp) { - DPRINT1("Pin_fnQuerySecurity called DeviceObject %p Irp %p\n", DeviceObject); + DPRINT("Pin_fnQuerySecurity called DeviceObject %p Irp %p\n", DeviceObject); Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; Irp->IoStatus.Information = 0; @@ -235,7 +235,7 @@ Pin_fnSetSecurity( PIRP Irp) { - DPRINT1("Pin_fnSetSecurity called DeviceObject %p Irp %p\n", DeviceObject); + DPRINT("Pin_fnSetSecurity called DeviceObject %p Irp %p\n", DeviceObject); Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; Irp->IoStatus.Information = 0; @@ -256,7 +256,7 @@ Pin_fnFastDeviceIoControl( PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject) { - DPRINT1("Pin_fnFastDeviceIoControl called DeviceObject %p Irp %p\n", DeviceObject); + DPRINT("Pin_fnFastDeviceIoControl called DeviceObject %p Irp %p\n", DeviceObject); return FALSE; @@ -275,7 +275,7 @@ Pin_fnFastRead( PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject) { - DPRINT1("Pin_fnFastRead called DeviceObject %p Irp %p\n", DeviceObject); + DPRINT("Pin_fnFastRead called DeviceObject %p Irp %p\n", DeviceObject); return FALSE; @@ -296,7 +296,7 @@ Pin_fnFastWrite( PDISPATCH_CONTEXT Context; NTSTATUS Status; - //DPRINT1("Pin_fnFastWrite called DeviceObject %p Irp %p\n", DeviceObject); + DPRINT("Pin_fnFastWrite called DeviceObject %p Irp %p\n", DeviceObject); Context = (PDISPATCH_CONTEXT)FileObject->FsContext2;