Skip to content

Commit

Permalink
[BDASUP][PORTCLS][SYSAUDIO][USB] Use ExAllocatePoolZero() and ExFreeP…
Browse files Browse the repository at this point in the history
…oolWithTag() (reactos#5811)
  • Loading branch information
SergeGautherie authored Oct 23, 2023
1 parent 7f5c59a commit 5b54477
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 75 deletions.
20 changes: 4 additions & 16 deletions drivers/multimedia/bdasup/bdasup.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

#include "precomp.h"

#define TAG_BDASUP 'SadB'

const GUID KSPROPSETID_BdaPinControl = {0xded49d5, 0xa8b7, 0x4d5d, {0x97, 0xa1, 0x12, 0xb0, 0xc1, 0x95, 0x87, 0x4d}};
const GUID KSMETHODSETID_BdaDeviceConfiguration = {0x71985f45, 0x1ca1, 0x11d3, {0x9c, 0xc8, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}};
const GUID KSPROPSETID_BdaTopology = {0xa14ee835, 0x0a23, 0x11d3, {0x9c, 0xc7, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}};
Expand All @@ -24,7 +26,6 @@ KSPROPERTY_ITEM FilterPropertyItem[] =
DEFINE_KSPROPERTY_ITEM_BDA_NODE_DESCRIPTORS(BdaPropertyNodeDescriptors, NULL)
};


KSPROPERTY_SET FilterPropertySet =
{
&KSPROPSETID_BdaTopology,
Expand Down Expand Up @@ -90,28 +91,21 @@ KSAUTOMATION_TABLE PinAutomationTable =
NULL
};


PVOID
AllocateItem(
IN POOL_TYPE PoolType,
IN SIZE_T NumberOfBytes)
{
PVOID Item = ExAllocatePool(PoolType, NumberOfBytes);
if (!Item)
return Item;

RtlZeroMemory(Item, NumberOfBytes);
return Item;
return ExAllocatePoolZero(PoolType, NumberOfBytes, TAG_BDASUP);
}

VOID
FreeItem(
IN PVOID Item)
{
ExFreePool(Item);
ExFreePoolWithTag(Item, TAG_BDASUP);
}


PBDA_FILTER_INSTANCE_ENTRY
GetFilterInstanceEntry(
IN PKSFILTERFACTORY FilterFactory)
Expand Down Expand Up @@ -141,7 +135,6 @@ GetFilterInstanceEntry(
InstanceEntry = NULL;
}


/* release spin lock */
KeReleaseSpinLock(&g_Settings.FilterFactoryInstanceListLock, OldLevel);

Expand Down Expand Up @@ -245,7 +238,6 @@ FreeFilterInstance(
KeReleaseSpinLock(&g_Settings.FilterFactoryInstanceListLock, OldLevel);
}


/*
@implemented
*/
Expand Down Expand Up @@ -339,7 +331,6 @@ BdaCreateFilterFactoryEx(
/* release spin lock */
KeReleaseSpinLock(&g_Settings.FilterFactoryInstanceListLock, OldLevel);


if (ppKSFilterFactory)
{
/* store result */
Expand Down Expand Up @@ -450,7 +441,6 @@ BdaCreatePin(
}
}


DPRINT("BdaCreatePin Result %x PinId %u\n", Status, PinId);
return Status;
}
Expand Down Expand Up @@ -543,8 +533,6 @@ BdaInitFilter(
return Status;
}



/*
@implemented
*/
Expand Down
14 changes: 2 additions & 12 deletions drivers/usb/usbccgp/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,8 @@ AllocateItem(
IN POOL_TYPE PoolType,
IN ULONG ItemSize)
{
/* Allocate item */
PVOID Item = ExAllocatePoolWithTag(PoolType, ItemSize, USBCCPG_TAG);

if (Item)
{
/* Zero item */
RtlZeroMemory(Item, ItemSize);
}

/* Return element */
return Item;
/* Allocate, zero and return item */
return ExAllocatePoolZero(PoolType, ItemSize, USBCCPG_TAG);
}

VOID
Expand All @@ -123,7 +114,6 @@ DumpFunctionDescriptor(
{
ULONG Index, SubIndex;


DPRINT("FunctionCount %lu\n", FunctionDescriptorCount);
for (Index = 0; Index < FunctionDescriptorCount; Index++)
{
Expand Down
10 changes: 1 addition & 9 deletions drivers/usb/usbstor/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#define NDEBUG
#include <debug.h>


IO_COMPLETION_ROUTINE SyncForwardIrpCompletionRoutine;

NTSTATUS
Expand Down Expand Up @@ -126,14 +125,7 @@ AllocateItem(
IN POOL_TYPE PoolType,
IN ULONG ItemSize)
{
PVOID Item = ExAllocatePoolWithTag(PoolType, ItemSize, USB_STOR_TAG);

if (Item)
{
RtlZeroMemory(Item, ItemSize);
}

return Item;
return ExAllocatePoolZero(PoolType, ItemSize, USB_STOR_TAG);
}

VOID
Expand Down
22 changes: 2 additions & 20 deletions drivers/usb/usbstor_new/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ USBSTOR_SyncForwardIrp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
//
IoSetCompletionRoutine(Irp, USBSTOR_SyncForwardIrpCompletionRoutine, &Event, TRUE, TRUE, TRUE);


//
// call driver
//
Expand Down Expand Up @@ -101,13 +100,11 @@ USBSTOR_GetBusInterface(
ASSERT(DeviceObject);
ASSERT(BusInterface);


//
// initialize event
//
KeInitializeEvent(&Event, NotificationEvent, FALSE);


//
// create irp
//
Expand Down Expand Up @@ -194,7 +191,6 @@ USBSTOR_SyncUrbRequest(
//
KeInitializeEvent(&Event, NotificationEvent, FALSE);


//
// get next stack location
//
Expand Down Expand Up @@ -252,22 +248,9 @@ AllocateItem(
IN ULONG ItemSize)
{
//
// allocate item
// allocate, zero and return item
//
PVOID Item = ExAllocatePoolWithTag(PoolType, ItemSize, USB_STOR_TAG);

if (Item)
{
//
// zero item
//
RtlZeroMemory(Item, ItemSize);
}

//
// return element
//
return Item;
return ExAllocatePoolZero(PoolType, ItemSize, USB_STOR_TAG);
}

VOID
Expand Down Expand Up @@ -333,7 +316,6 @@ USBSTOR_ClassRequest(
return Status;
}


NTSTATUS
USBSTOR_GetMaxLUN(
IN PDEVICE_OBJECT DeviceObject,
Expand Down
9 changes: 1 addition & 8 deletions drivers/wdm/audio/backpln/portcls/pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#ifndef YDEBUG
#define NDEBUG
#endif

#include <debug.h>

PVOID
Expand All @@ -20,19 +19,13 @@ AllocateItem(
IN SIZE_T NumberOfBytes,
IN ULONG Tag)
{
PVOID Item = ExAllocatePoolWithTag(PoolType, NumberOfBytes, Tag);
if (!Item)
return Item;

RtlZeroMemory(Item, NumberOfBytes);
return Item;
return ExAllocatePoolZero(PoolType, NumberOfBytes, Tag);
}

VOID
FreeItem(
IN PVOID Item,
IN ULONG Tag)
{

ExFreePoolWithTag(Item, Tag);
}
14 changes: 4 additions & 10 deletions drivers/wdm/audio/sysaudio/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#define NDEBUG
#include <debug.h>

#define TAG_SYSAUDIO 'AsyS'

const GUID KSCATEGORY_SYSAUDIO = {0xA7C7A5B1L, 0x5AF3, 0x11D1, {0x9C, 0xED, 0x00, 0xA0, 0x24, 0xBF, 0x04, 0x07}};
const GUID KSCATEGORY_AUDIO_DEVICE = {0xFBF6F530L, 0x07B9, 0x11D2, {0xA7, 0x1E, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88}};
const GUID KSCATEGORY_PREFERRED_WAVEOUT_DEVICE = {0xD6C5066EL, 0x72C1, 0x11D2, {0x97, 0x55, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88}};
Expand All @@ -25,22 +27,16 @@ AllocateItem(
IN POOL_TYPE PoolType,
IN SIZE_T NumberOfBytes)
{
PVOID Item = ExAllocatePool(PoolType, NumberOfBytes);
if (!Item)
return Item;

RtlZeroMemory(Item, NumberOfBytes);
return Item;
return ExAllocatePoolZero(PoolType, NumberOfBytes, TAG_SYSAUDIO);
}

VOID
FreeItem(
IN PVOID Item)
{
ExFreePool(Item);
ExFreePoolWithTag(Item, TAG_SYSAUDIO);
}


VOID
NTAPI
SysAudio_Unload(IN PDRIVER_OBJECT DriverObject)
Expand Down Expand Up @@ -88,7 +84,6 @@ SysAudio_Shutdown(
return STATUS_SUCCESS;
}


NTSTATUS
NTAPI
SysAudio_Pnp(
Expand Down Expand Up @@ -222,7 +217,6 @@ SysAudio_AddDevice(
/* register shutdown notification */
IoRegisterShutdownNotification(DeviceObject);


/* Done */
return STATUS_SUCCESS;

Expand Down

0 comments on commit 5b54477

Please sign in to comment.