diff options
| author | Andrew Maczugowski <[email protected]> | 2021-01-14 14:55:13 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-01-14 11:55:13 -0800 |
| commit | 31ef0db3ef36b4d1949ae9c8e2760a7f499d1113 (patch) | |
| tree | 286dd17993cc3ac63cb9c6c56cd4e69e97e49f40 | |
| parent | 86e7b24148d1aafcf2d5c76d602561dddbd8fd0b (diff) | |
classpnp: Use ExAllocatePoolZero instead of ExAllocatePoolWithTag (#485)
* Replace unsafe allocation API with ExAllocatePool2
* Fix for downlevel support.
Co-authored-by: Drew Maczugowski <[email protected]>
| -rw-r--r-- | storage/class/classpnp/src/autorun.c | 43 | ||||
| -rw-r--r-- | storage/class/classpnp/src/class.c | 182 | ||||
| -rw-r--r-- | storage/class/classpnp/src/classp.h | 1 | ||||
| -rw-r--r-- | storage/class/classpnp/src/classwmi.c | 3 | ||||
| -rw-r--r-- | storage/class/classpnp/src/debug.c | 5 | ||||
| -rw-r--r-- | storage/class/classpnp/src/dictlib.c | 7 | ||||
| -rw-r--r-- | storage/class/classpnp/src/lock.c | 9 | ||||
| -rw-r--r-- | storage/class/classpnp/src/power.c | 4 | ||||
| -rw-r--r-- | storage/class/classpnp/src/srblib.c | 2 | ||||
| -rw-r--r-- | storage/class/classpnp/src/utils.c | 138 | ||||
| -rw-r--r-- | storage/class/classpnp/src/xferpkt.c | 69 |
11 files changed, 239 insertions, 224 deletions
diff --git a/storage/class/classpnp/src/autorun.c b/storage/class/classpnp/src/autorun.c index f0a88414..5cb5ca3d 100644 --- a/storage/class/classpnp/src/autorun.c +++ b/storage/class/classpnp/src/autorun.c @@ -210,9 +210,9 @@ ClassSendNotification( return; } - notification = ExAllocatePoolWithTag(NonPagedPoolNx, - requiredSize, - 'oNcS'); + notification = ExAllocatePoolZero(NonPagedPoolNx, + requiredSize, + 'oNcS'); // // if none allocated, exit @@ -226,7 +226,6 @@ ClassSendNotification( // Prepare and send the request! // - RtlZeroMemory(notification, requiredSize); notification->Version = 1; notification->Size = (USHORT)(requiredSize); notification->FileObject = NULL; @@ -1838,13 +1837,11 @@ ClasspInitializePolling( return STATUS_SUCCESS; } - info = ExAllocatePoolWithTag(NonPagedPoolNx, - sizeof(MEDIA_CHANGE_DETECTION_INFO), - CLASS_TAG_MEDIA_CHANGE_DETECTION); + info = ExAllocatePoolZero(NonPagedPoolNx, + sizeof(MEDIA_CHANGE_DETECTION_INFO), + CLASS_TAG_MEDIA_CHANGE_DETECTION); if (info != NULL) { - RtlZeroMemory(info, sizeof(MEDIA_CHANGE_DETECTION_INFO)); - FdoExtension->KernelModeMcnContext.FileObject = (PVOID)-1; FdoExtension->KernelModeMcnContext.DeviceObject = (PVOID)-1; FdoExtension->KernelModeMcnContext.LockCount = 0; @@ -1862,10 +1859,10 @@ ClasspInitializePolling( PVOID buffer; BOOLEAN GesnSupported = FALSE; - buffer = ExAllocatePoolWithTag( - NonPagedPoolNxCacheAligned, - SENSE_BUFFER_SIZE_EX, - CLASS_TAG_MEDIA_CHANGE_DETECTION); + buffer = ExAllocatePoolZero( + NonPagedPoolNxCacheAligned, + SENSE_BUFFER_SIZE_EX, + CLASS_TAG_MEDIA_CHANGE_DETECTION); if (buffer != NULL) { @@ -2032,9 +2029,10 @@ ClasspInitializeGesn( // if (Info->Gesn.Buffer == NULL) { - Info->Gesn.Buffer = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, - GESN_BUFFER_SIZE, - '??cS'); + Info->Gesn.Buffer = ExAllocatePoolZero( + NonPagedPoolNxCacheAligned, + GESN_BUFFER_SIZE, + '??cS'); } if (Info->Gesn.Buffer == NULL) { status = STATUS_INSUFFICIENT_RESOURCES; @@ -2816,10 +2814,9 @@ ClasspIsMediaChangeDisabledDueToHardwareLimitation( deviceString.Length = (USHORT)( length ); deviceString.MaximumLength = deviceString.Length + 1; - deviceString.Buffer = (PCHAR)ExAllocatePoolWithTag( NonPagedPoolNx, - deviceString.MaximumLength, - CLASS_TAG_AUTORUN_DISABLE - ); + deviceString.Buffer = (PCHAR)ExAllocatePoolZero( NonPagedPoolNx, + deviceString.MaximumLength, + CLASS_TAG_AUTORUN_DISABLE ); if (deviceString.Buffer == NULL) { TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_MCN, "ClassMediaChangeDisabledForHardware: Unable to alloc " @@ -4277,9 +4274,9 @@ ClassSetFailurePredictionPoll( if (FailurePredictionMethod != FailurePredictionNone) { - info = ExAllocatePoolWithTag(NonPagedPoolNx, - sizeof(FAILURE_PREDICTION_INFO), - CLASS_TAG_FAILURE_PREDICT); + info = ExAllocatePoolZero(NonPagedPoolNx, + sizeof(FAILURE_PREDICTION_INFO), + CLASS_TAG_FAILURE_PREDICT); if (info == NULL) { diff --git a/storage/class/classpnp/src/class.c b/storage/class/classpnp/src/class.c index 5e7f00f1..58d1835a 100644 --- a/storage/class/classpnp/src/class.c +++ b/storage/class/classpnp/src/class.c @@ -222,6 +222,11 @@ ClassInitialize( PAGED_CODE(); // + // Must be called before calling pool allocation functions. + // + ExInitializeDriverRuntime(0); + + // // Initialize the security cookie if needed. // if (InitSecurityCookie == FALSE) { @@ -348,9 +353,9 @@ ClassInitialize( driverExtension->RegistryPath.MaximumLength = RegistryPath->MaximumLength; driverExtension->RegistryPath.Buffer = - ExAllocatePoolWithTag(PagedPool, - RegistryPath->MaximumLength, - '1CcS'); + ExAllocatePoolZero(PagedPool, + RegistryPath->MaximumLength, + '1CcS'); if(driverExtension->RegistryPath.Buffer == NULL) { @@ -557,10 +562,9 @@ ClassInitializeEx( } else { - info = ExAllocatePoolWithTag(NonPagedPoolNx, - sizeof(CLASS_WORKING_SET), - CLASS_TAG_WORKING_SET - ); + info = ExAllocatePoolZero(NonPagedPoolNx, + sizeof(CLASS_WORKING_SET), + CLASS_TAG_WORKING_SET); if (info == NULL) { status = STATUS_INSUFFICIENT_RESOURCES; @@ -626,10 +630,9 @@ ClassInitializeEx( } else { - info = ExAllocatePoolWithTag(NonPagedPoolNx, - sizeof(CLASS_INTERPRET_SENSE_INFO2), - CLASS_TAG_SENSE2 - ); + info = ExAllocatePoolZero(NonPagedPoolNx, + sizeof(CLASS_INTERPRET_SENSE_INFO2), + CLASS_TAG_SENSE2); if (info == NULL) { status = STATUS_INSUFFICIENT_RESOURCES; @@ -960,15 +963,12 @@ ClassDispatchPnp( status = STATUS_INSUFFICIENT_RESOURCES; - deviceRelations = ExAllocatePoolWithTag(PagedPool, - sizeof(DEVICE_RELATIONS), - '2CcS'); + deviceRelations = ExAllocatePoolZero(PagedPool, + sizeof(DEVICE_RELATIONS), + '2CcS'); if(deviceRelations != NULL) { - RtlZeroMemory(deviceRelations, - sizeof(DEVICE_RELATIONS)); - Irp->IoStatus.Information = (ULONG_PTR) deviceRelations; deviceRelations->Count = 1; @@ -1836,10 +1836,10 @@ NTSTATUS ClassPnpStartDevice(IN PDEVICE_OBJECT DeviceObject) // if (fdoExtension->PrivateFdoData == NULL) { - fdoExtension->PrivateFdoData = ExAllocatePoolWithTag(NonPagedPoolNx, - sizeof(CLASS_PRIVATE_FDO_DATA), - CLASS_TAG_PRIVATE_DATA - ); + fdoExtension->PrivateFdoData = ExAllocatePoolZero( + NonPagedPoolNx, + sizeof(CLASS_PRIVATE_FDO_DATA), + CLASS_TAG_PRIVATE_DATA); } if (fdoExtension->PrivateFdoData == NULL) { @@ -1856,10 +1856,10 @@ NTSTATUS ClassPnpStartDevice(IN PDEVICE_OBJECT DeviceObject) // This structure's memory is managed by classpnp, so it is more extensible. // if (fdoExtension->AdditionalFdoData == NULL) { - fdoExtension->AdditionalFdoData = ExAllocatePoolWithTag(NonPagedPoolNx, - sizeof(ADDITIONAL_FDO_DATA), - CLASSPNP_POOL_TAG_ADDITIONAL_DATA - ); + fdoExtension->AdditionalFdoData = ExAllocatePoolZero( + NonPagedPoolNx, + sizeof(ADDITIONAL_FDO_DATA), + CLASSPNP_POOL_TAG_ADDITIONAL_DATA); } if (fdoExtension->AdditionalFdoData == NULL) { @@ -1885,10 +1885,11 @@ NTSTATUS ClassPnpStartDevice(IN PDEVICE_OBJECT DeviceObject) // if (fdoExtension->FunctionSupportInfo == NULL) { - fdoExtension->FunctionSupportInfo = (PCLASS_FUNCTION_SUPPORT_INFO)ExAllocatePoolWithTag(NonPagedPoolNx, - sizeof(CLASS_FUNCTION_SUPPORT_INFO), - '3BcS' - ); + fdoExtension->FunctionSupportInfo = + (PCLASS_FUNCTION_SUPPORT_INFO)ExAllocatePoolZero( + NonPagedPoolNx, + sizeof(CLASS_FUNCTION_SUPPORT_INFO), + '3BcS'); } if (fdoExtension->FunctionSupportInfo == NULL) { @@ -3051,9 +3052,9 @@ ClassSendStartUnit( // Allocate Srb from nonpaged pool. // - context = ExAllocatePoolWithTag(NonPagedPoolNx, - sizeof(COMPLETION_CONTEXT), - '6CcS'); + context = ExAllocatePoolZero(NonPagedPoolNx, + sizeof(COMPLETION_CONTEXT), + '6CcS'); if (context == NULL) { @@ -4068,9 +4069,9 @@ ClassSendSrbSynchronous( #endif - senseInfoBuffer = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, - senseInfoBufferLength, - '7CcS'); + senseInfoBuffer = ExAllocatePoolZero(NonPagedPoolNxCacheAligned, + senseInfoBufferLength, + '7CcS'); if (senseInfoBuffer == NULL) { @@ -7443,7 +7444,7 @@ ClassDeviceControl( break; } - valueName = ExAllocatePoolWithTag( + valueName = ExAllocatePoolZero( PagedPool, commonExtension->DeviceName.Length + sizeof(WCHAR), '8CcS'); @@ -7561,10 +7562,9 @@ ClassDeviceControl( sizeNeeded = sizeof(SCSI_REQUEST_BLOCK); } - srb = ExAllocatePoolWithTag(NonPagedPoolNx, - sizeNeeded + - (sizeof(ULONG_PTR) * 2), - '9CcS'); + srb = ExAllocatePoolZero(NonPagedPoolNx, + sizeNeeded + (sizeof(ULONG_PTR) * 2), + '9CcS'); if (srb == NULL) { @@ -7593,7 +7593,6 @@ ClassDeviceControl( goto SetStatusAndReturn; } } else { - RtlZeroMemory(srb, sizeof(SCSI_REQUEST_BLOCK)); srb->Length = sizeof(SCSI_REQUEST_BLOCK); srb->Function = SRB_FUNCTION_EXECUTE_SCSI; function = (PULONG_PTR) ((PSCSI_REQUEST_BLOCK) (srb + 1)); @@ -9431,16 +9430,16 @@ ClassQueryTimeOutRegistryValue( return 0; } - parameters = ExAllocatePoolWithTag(NonPagedPoolNx, - sizeof(RTL_QUERY_REGISTRY_TABLE)*2, - '1BcS'); + parameters = ExAllocatePoolZero(NonPagedPoolNx, + sizeof(RTL_QUERY_REGISTRY_TABLE) * 2, + '1BcS'); if (!parameters) { return 0; } size = registryPath->MaximumLength + sizeof(WCHAR); - path = ExAllocatePoolWithTag(NonPagedPoolNx, size, '2BcS'); + path = ExAllocatePoolZero(NonPagedPoolNx, size, '2BcS'); if (!path) { FREE_POOL(parameters); @@ -9455,9 +9454,6 @@ ClassQueryTimeOutRegistryValue( // Check for the Timeout value. // - RtlZeroMemory(parameters, - (sizeof(RTL_QUERY_REGISTRY_TABLE)*2)); - parameters[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_TYPECHECK; parameters[0].Name = L"TimeOutValue"; parameters[0].EntryContext = &timeOut; @@ -9625,7 +9621,7 @@ ClassGetDescriptor( if(!NT_SUCCESS(ioStatus.Status)) { - TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_INIT, "ClassGetDescriptor: error %lx trying to " + TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_INIT, "ClassGetDescriptor: error %lx trying to " "query properties #1\n", ioStatus.Status)); return ioStatus.Status; } @@ -9651,7 +9647,7 @@ ClassGetDescriptor( NT_ASSERT(length >= sizeof(STORAGE_PROPERTY_QUERY)); length = max(length, sizeof(STORAGE_PROPERTY_QUERY)); - descriptor = ExAllocatePoolWithTag(NonPagedPoolNx, length, '4BcS'); + descriptor = ExAllocatePoolZero(NonPagedPoolNx, length, '4BcS'); if(descriptor == NULL) { @@ -9672,8 +9668,6 @@ ClassGetDescriptor( // copy the input to the new outputbuffer // - RtlZeroMemory(descriptor, length); - RtlCopyMemory(descriptor, &query, sizeof(STORAGE_PROPERTY_QUERY) @@ -9989,7 +9983,7 @@ ClassRetrieveDeviceRelations( relationsSize = (sizeof(DEVICE_RELATIONS) + (count * sizeof(PDEVICE_OBJECT))); - deviceRelations = ExAllocatePoolWithTag(PagedPool, relationsSize, '5BcS'); + deviceRelations = ExAllocatePoolZero(PagedPool, relationsSize, '5BcS'); if (deviceRelations == NULL) { @@ -10001,8 +9995,6 @@ ClassRetrieveDeviceRelations( return STATUS_INSUFFICIENT_RESOURCES; } - RtlZeroMemory(deviceRelations, relationsSize); - if (oldRelations) { // @@ -11056,9 +11048,11 @@ ClassSendDeviceIoControlSynchronous( { if ((InputBufferLength != 0) || (OutputBufferLength != 0)) { - irp->AssociatedIrp.SystemBuffer = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, - max(InputBufferLength, OutputBufferLength), - CLASS_TAG_DEVICE_CONTROL); + irp->AssociatedIrp.SystemBuffer = + ExAllocatePoolZero(NonPagedPoolNxCacheAligned, + max(InputBufferLength, OutputBufferLength), + CLASS_TAG_DEVICE_CONTROL); + if (irp->AssociatedIrp.SystemBuffer == NULL) { IoFreeIrp(irp); @@ -11543,10 +11537,9 @@ ClasspAllocateReleaseQueueIrp( NT_ASSERT(!(FdoExtension->ReleaseQueueInProgress)); FdoExtension->PrivateFdoData->ReleaseQueueIrp = - ExAllocatePoolWithTag(NonPagedPoolNx, - IoSizeOfIrp(lowerStackSize), - CLASS_TAG_RELEASE_QUEUE - ); + ExAllocatePoolZero(NonPagedPoolNx, + IoSizeOfIrp(lowerStackSize), + CLASS_TAG_RELEASE_QUEUE); if (FdoExtension->PrivateFdoData->ReleaseQueueIrp == NULL) { TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_PNP, "ClassPnpStartDevice: Cannot allocate for " @@ -11590,10 +11583,10 @@ ClasspAllocatePowerProcessIrp( stackSize = FdoExtension->CommonExtension.LowerDeviceObject->StackSize + 1; - FdoExtension->PrivateFdoData->PowerProcessIrp = ExAllocatePoolWithTag(NonPagedPoolNx, - IoSizeOfIrp(stackSize), - CLASS_TAG_POWER - ); + FdoExtension->PrivateFdoData->PowerProcessIrp = + ExAllocatePoolZero(NonPagedPoolNx, + IoSizeOfIrp(stackSize), + CLASS_TAG_POWER); if (FdoExtension->PrivateFdoData->PowerProcessIrp == NULL) { @@ -12824,17 +12817,15 @@ ClasspGetInquiryVpdSupportInfo( // ARM has specific alignment requirements, although this will not have a functional impact on x86 or amd64 // based platforms. We are taking the conservative approach here. // - allocationBufferLength = ALIGN_UP_BY(allocationBufferLength,KeGetRecommendedSharedDataAlignment()); - supportedPages = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, - allocationBufferLength, - '3CcS' - ); + allocationBufferLength = ALIGN_UP_BY(allocationBufferLength , KeGetRecommendedSharedDataAlignment()); + supportedPages = ExAllocatePoolZero(NonPagedPoolNxCacheAligned, + allocationBufferLength, + '3CcS'); #else - supportedPages = ExAllocatePoolWithTag(NonPagedPoolNx, - bufferLength, - '3CcS' - ); + supportedPages = ExAllocatePoolZero(NonPagedPoolNx, + bufferLength, + '3CcS'); #endif if (supportedPages == NULL) { @@ -12842,8 +12833,6 @@ ClasspGetInquiryVpdSupportInfo( return; } - RtlZeroMemory(supportedPages, allocationBufferLength); - // prepare the Srb if (FdoExtension->AdapterDescriptor->SrbType == SRB_TYPE_STORAGE_REQUEST_BLOCK) { @@ -13006,7 +12995,7 @@ ClasspGetLBProvisioningInfo( srbSize = sizeof(SCSI_REQUEST_BLOCK); } - srb = ExAllocatePoolWithTag(NonPagedPoolNx, srbSize, '0DcS'); + srb = ExAllocatePoolZero(NonPagedPoolNx, srbSize, '0DcS'); if (srb == NULL) { return STATUS_INSUFFICIENT_RESOURCES; @@ -13162,7 +13151,7 @@ Return Value: srbSize = sizeof(SCSI_REQUEST_BLOCK); } - srb = ExAllocatePoolWithTag(NonPagedPoolNx, srbSize, CLASSPNP_POOL_TAG_SRB); + srb = ExAllocatePoolZero(NonPagedPoolNx, srbSize, CLASSPNP_POOL_TAG_SRB); if (!srb) { @@ -13181,9 +13170,13 @@ Return Value: // based platforms. We are taking the conservative approach here. // allocationBufferLength = ALIGN_UP_BY(allocationBufferLength, KeGetRecommendedSharedDataAlignment()); - dataBuffer = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, allocationBufferLength, CLASSPNP_POOL_TAG_VPD); + dataBuffer = ExAllocatePoolZero(NonPagedPoolNxCacheAligned, + allocationBufferLength, + CLASSPNP_POOL_TAG_VPD); #else - dataBuffer = ExAllocatePoolWithTag(NonPagedPoolNx, bufferLength, CLASSPNP_POOL_TAG_VPD); + dataBuffer = ExAllocatePoolZero(NonPagedPoolNx, + bufferLength, + CLASSPNP_POOL_TAG_VPD); #endif if (!dataBuffer) { @@ -13199,8 +13192,6 @@ Return Value: operatingParameters = (PVPD_THIRD_PARTY_COPY_PAGE)dataBuffer; - RtlZeroMemory(dataBuffer, allocationBufferLength); - if ((fdoExtension->AdapterDescriptor != NULL) && (fdoExtension->AdapterDescriptor->SrbType == SRB_TYPE_STORAGE_REQUEST_BLOCK)) { status = InitializeStorageRequestBlock((PSTORAGE_REQUEST_BLOCK)srb, @@ -13230,7 +13221,6 @@ Return Value: } } else { - RtlZeroMemory(srb, sizeof(SCSI_REQUEST_BLOCK)); srb->Length = sizeof(SCSI_REQUEST_BLOCK); srb->Function = SRB_FUNCTION_EXECUTE_SCSI; } @@ -13816,10 +13806,9 @@ Return Value: allocationSize = sizeof(OFFLOAD_READ_CONTEXT) + bufferLength; - offloadReadContext = ExAllocatePoolWithTag( - NonPagedPoolNx, - allocationSize, - CLASSPNP_POOL_TAG_TOKEN_OPERATION); + offloadReadContext = ExAllocatePoolZero(NonPagedPoolNx, + allocationSize, + CLASSPNP_POOL_TAG_TOKEN_OPERATION); if (!offloadReadContext) { @@ -13832,8 +13821,6 @@ Return Value: goto __ClasspServicePopulateTokenTransferRequest_ErrorExit; } - RtlZeroMemory(offloadReadContext, allocationSize); - offloadReadContext->Fdo = Fdo; offloadReadContext->OffloadReadDsmIrp = Irp; @@ -14885,10 +14872,9 @@ Return Value: allocationSize = sizeof(OFFLOAD_WRITE_CONTEXT) + bufferLength; - offloadWriteContext = ExAllocatePoolWithTag( - NonPagedPoolNx, - allocationSize, - CLASSPNP_POOL_TAG_TOKEN_OPERATION); + offloadWriteContext = ExAllocatePoolZero(NonPagedPoolNx, + allocationSize, + CLASSPNP_POOL_TAG_TOKEN_OPERATION); if (!offloadWriteContext) { @@ -14901,12 +14887,6 @@ Return Value: goto __ClasspServiceWriteUsingTokenTransferRequest_ErrorExit; } - // - // Only zero the context portion here. The buffer portion is zeroed for - // each sub-request. - // - RtlZeroMemory(offloadWriteContext, sizeof(OFFLOAD_WRITE_CONTEXT)); - offloadWriteContext->Fdo = Fdo; offloadWriteContext->OffloadWriteDsmIrp = Irp; offloadWriteContext->OperationStartTime = KeQueryInterruptTime(); @@ -16343,7 +16323,7 @@ Return Value: srbSize = sizeof(SCSI_REQUEST_BLOCK); } - srb = ExAllocatePoolWithTag(NonPagedPoolNx, srbSize, '1DcS'); + srb = ExAllocatePoolZero(NonPagedPoolNx, srbSize, '1DcS'); if (srb == NULL) { return STATUS_INSUFFICIENT_RESOURCES; } diff --git a/storage/class/classpnp/src/classp.h b/storage/class/classpnp/src/classp.h index d7d57e9d..1e2331c2 100644 --- a/storage/class/classpnp/src/classp.h +++ b/storage/class/classpnp/src/classp.h @@ -26,6 +26,7 @@ Revision History: --*/ #define RTL_USE_AVL_TABLES 0 +#define POOL_ZERO_DOWN_LEVEL_SUPPORT #include <stddef.h> #include <stdarg.h> diff --git a/storage/class/classpnp/src/classwmi.c b/storage/class/classpnp/src/classwmi.c index 1b1eeeee..e21ec356 100644 --- a/storage/class/classpnp/src/classwmi.c +++ b/storage/class/classpnp/src/classwmi.c @@ -1175,10 +1175,9 @@ ClassWmiFireEvent( sizeNeeded = sizeof(WNODE_SINGLE_INSTANCE) + EventDataSize; - event = ExAllocatePoolWithTag(NonPagedPoolNx, sizeNeeded, CLASS_TAG_WMI); + event = ExAllocatePoolZero(NonPagedPoolNx, sizeNeeded, CLASS_TAG_WMI); if (event != NULL) { - RtlZeroMemory(event, sizeNeeded); event->WnodeHeader.Guid = *Guid; event->WnodeHeader.ProviderId = IoWMIDeviceObjectToProviderId(DeviceObject); event->WnodeHeader.BufferSize = sizeNeeded; diff --git a/storage/class/classpnp/src/debug.c b/storage/class/classpnp/src/debug.c index cc288ec6..b811c6d0 100644 --- a/storage/class/classpnp/src/debug.c +++ b/storage/class/classpnp/src/debug.c @@ -165,8 +165,9 @@ Revision History: "ClassDebugPrint: Allocating %x bytes for " "classdebugprint buffer\n", (ULONG)bufferSize); ClasspnpGlobals.Index = (ULONG)-1; - ClasspnpGlobals.Buffer = - ExAllocatePoolWithTag(NonPagedPoolNx, bufferSize, 'bDcS'); + ClasspnpGlobals.Buffer = ExAllocatePoolZero(NonPagedPoolNx, + bufferSize, + 'bDcS'); DbgPrintEx(DPFLTR_CLASSPNP_ID, DPFLTR_ERROR_LEVEL, "ClassDebugPrint: Allocated buffer at %p\n", ClasspnpGlobals.Buffer); diff --git a/storage/class/classpnp/src/dictlib.c b/storage/class/classpnp/src/dictlib.c index 90a67117..73a7e5ca 100644 --- a/storage/class/classpnp/src/dictlib.c +++ b/storage/class/classpnp/src/dictlib.c @@ -78,15 +78,14 @@ AllocateDictionaryEntry( *Entry = NULL; - header = ExAllocatePoolWithTag(NonPagedPoolNx, - Size + sizeof(DICTIONARY_HEADER), - Tag); + header = ExAllocatePoolZero(NonPagedPoolNx, + Size + sizeof(DICTIONARY_HEADER), + Tag); if(header == NULL) { return STATUS_INSUFFICIENT_RESOURCES; } - RtlZeroMemory(header, sizeof(DICTIONARY_HEADER) + Size); header->Key = Key; // diff --git a/storage/class/classpnp/src/lock.c b/storage/class/classpnp/src/lock.c index 1b5a8862..1d0d240c 100644 --- a/storage/class/classpnp/src/lock.c +++ b/storage/class/classpnp/src/lock.c @@ -472,7 +472,9 @@ RemoveTrackingAllocateRoutine( { UNREFERENCED_PARAMETER(Table); - return ExAllocatePoolWithTag(NonPagedPoolNx, ByteSize, CLASS_TAG_LOCK_TRACKING); + return ExAllocatePoolZero(NonPagedPoolNx, + ByteSize, + CLASS_TAG_LOCK_TRACKING); } VOID @@ -496,7 +498,10 @@ ClasspInitializeRemoveTracking( #if DBG KeInitializeSpinLock(&commonExtension->RemoveTrackingSpinlock); - commonExtension->RemoveTrackingList = ExAllocatePoolWithTag(NonPagedPoolNx, sizeof(RTL_GENERIC_TABLE), CLASS_TAG_LOCK_TRACKING); + commonExtension->RemoveTrackingList = + ExAllocatePoolZero(NonPagedPoolNx, + sizeof(RTL_GENERIC_TABLE), + CLASS_TAG_LOCK_TRACKING); if (commonExtension->RemoveTrackingList != NULL) { diff --git a/storage/class/classpnp/src/power.c b/storage/class/classpnp/src/power.c index 790dba4a..75a6c05d 100644 --- a/storage/class/classpnp/src/power.c +++ b/storage/class/classpnp/src/power.c @@ -2615,7 +2615,9 @@ Return Value: // // Put this FDO on the list of devices that are idle power managed. // - fdoEntry = ExAllocatePoolWithTag(NonPagedPoolNx, sizeof(IDLE_POWER_FDO_LIST_ENTRY), CLASS_TAG_POWER); + fdoEntry = ExAllocatePoolZero(NonPagedPoolNx, + sizeof(IDLE_POWER_FDO_LIST_ENTRY), + CLASS_TAG_POWER); if (fdoEntry) { fdoExtension->FunctionSupportInfo->IdlePower.IdlePowerEnabled = TRUE; diff --git a/storage/class/classpnp/src/srblib.c b/storage/class/classpnp/src/srblib.c index 64a7ca88..f56ae419 100644 --- a/storage/class/classpnp/src/srblib.c +++ b/storage/class/classpnp/src/srblib.c @@ -44,7 +44,7 @@ Return Value: --*/ { - return ExAllocatePoolWithTag(NonPagedPoolNx, ByteSize, '+brs'); + return ExAllocatePoolZero(NonPagedPoolNx, ByteSize, '+brs'); } diff --git a/storage/class/classpnp/src/utils.c b/storage/class/classpnp/src/utils.c index 323d7449..120031eb 100644 --- a/storage/class/classpnp/src/utils.c +++ b/storage/class/classpnp/src/utils.c @@ -1296,9 +1296,9 @@ NTSTATUS ClasspWriteCacheProperty( status = STATUS_SUCCESS; } - modeData = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, - MODE_PAGE_DATA_SIZE, - CLASS_TAG_MODE_DATA); + modeData = ExAllocatePoolZero(NonPagedPoolNxCacheAligned, + MODE_PAGE_DATA_SIZE, + CLASS_TAG_MODE_DATA); if (modeData == NULL) { TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL, "ClasspWriteCacheProperty: Unable to allocate mode data buffer\n")); @@ -1306,8 +1306,6 @@ NTSTATUS ClasspWriteCacheProperty( goto WriteCacheExit; } - RtlZeroMemory(modeData, MODE_PAGE_DATA_SIZE); - length = ClassModeSense(DeviceObject, (PCHAR) modeData, MODE_PAGE_DATA_SIZE, @@ -1598,10 +1596,16 @@ ClassReadCapacity16 ( // ARM has specific alignment requirements, although this will not have a functional impact on x86 or amd64 // based platforms. We are taking the conservative approach here. // - allocationBufferLength = ALIGN_UP_BY(allocationBufferLength,KeGetRecommendedSharedDataAlignment()); - dataBuffer = (PREAD_CAPACITY16_DATA)ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, allocationBufferLength, '4CcS'); + allocationBufferLength = ALIGN_UP_BY(allocationBufferLength, KeGetRecommendedSharedDataAlignment()); + dataBuffer = (PREAD_CAPACITY16_DATA) + ExAllocatePoolZero(NonPagedPoolNxCacheAligned, + allocationBufferLength, + '4CcS'); #else - dataBuffer = (PREAD_CAPACITY16_DATA)ExAllocatePoolWithTag(NonPagedPoolNx, bufferLength, '4CcS'); + dataBuffer = (PREAD_CAPACITY16_DATA) + ExAllocatePoolZero(NonPagedPoolNx, + bufferLength, + '4CcS'); #endif if (dataBuffer == NULL) { @@ -1610,8 +1614,6 @@ ClassReadCapacity16 ( return STATUS_INSUFFICIENT_RESOURCES; } - RtlZeroMemory(dataBuffer, allocationBufferLength); - // // Initialize the SRB. // @@ -2097,25 +2099,23 @@ Return Value: // ARM has specific alignment requirements, although this will not have a functional impact on x86 or amd64 // based platforms. We are taking the conservative approach here. // - allocationBufferLength = ALIGN_UP_BY(allocationBufferLength,KeGetRecommendedSharedDataAlignment()); - dataBuffer = (PVPD_BLOCK_DEVICE_CHARACTERISTICS_PAGE)ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, - allocationBufferLength, - '5CcS' - ); + allocationBufferLength = ALIGN_UP_BY(allocationBufferLength, KeGetRecommendedSharedDataAlignment()); + dataBuffer = (PVPD_BLOCK_DEVICE_CHARACTERISTICS_PAGE) + ExAllocatePoolZero(NonPagedPoolNxCacheAligned, + allocationBufferLength, + '5CcS'); #else - dataBuffer = (PVPD_BLOCK_DEVICE_CHARACTERISTICS_PAGE)ExAllocatePoolWithTag(NonPagedPoolNx, - bufferLength, - '5CcS' - ); + dataBuffer = (PVPD_BLOCK_DEVICE_CHARACTERISTICS_PAGE) + ExAllocatePoolZero(NonPagedPoolNx, + bufferLength, + '5CcS'); #endif if (dataBuffer == NULL) { status = STATUS_INSUFFICIENT_RESOURCES; goto Exit; } - RtlZeroMemory(dataBuffer, allocationBufferLength); - // prepare the Srb SrbSetTimeOutValue(Srb, fdoExtension->TimeOutValue); SrbSetRequestTag(Srb, SP_UNTAGGED); @@ -2384,10 +2384,14 @@ NTSTATUS ClasspDeviceGetLBProvisioningVPDPage( // based platforms. We are taking the conservative approach here. // // - allocationBufferLength = ALIGN_UP_BY(allocationBufferLength,KeGetRecommendedSharedDataAlignment()); - dataBuffer = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, allocationBufferLength,'0CcS'); + allocationBufferLength = ALIGN_UP_BY(allocationBufferLength, KeGetRecommendedSharedDataAlignment()); + dataBuffer = ExAllocatePoolZero(NonPagedPoolNxCacheAligned, + allocationBufferLength, + '0CcS'); #else - dataBuffer = ExAllocatePoolWithTag(NonPagedPoolNx, bufferLength,'0CcS'); + dataBuffer = ExAllocatePoolZero(NonPagedPoolNx, + bufferLength, + '0CcS'); #endif if (dataBuffer == NULL) { // return without updating FdoExtension->FunctionSupportInfo->LBProvisioningData.CommandStatus @@ -2398,8 +2402,6 @@ NTSTATUS ClasspDeviceGetLBProvisioningVPDPage( lbProvisioning = (PVPD_LOGICAL_BLOCK_PROVISIONING_PAGE)dataBuffer; - RtlZeroMemory(dataBuffer, allocationBufferLength); - if (fdoExtension->AdapterDescriptor->SrbType == SRB_TYPE_STORAGE_REQUEST_BLOCK) { status = InitializeStorageRequestBlock((PSTORAGE_REQUEST_BLOCK)Srb, STORAGE_ADDRESS_TYPE_BTL8, @@ -2559,9 +2561,13 @@ NTSTATUS ClasspDeviceGetBlockLimitsVPDPage( // based platforms. We are taking the conservative approach here. // allocationBufferLength = ALIGN_UP_BY(allocationBufferLength, KeGetRecommendedSharedDataAlignment()); - dataBuffer = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, allocationBufferLength, '0CcS'); + dataBuffer = ExAllocatePoolZero(NonPagedPoolNxCacheAligned, + allocationBufferLength, + '0CcS'); #else - dataBuffer = ExAllocatePoolWithTag(NonPagedPoolNx, bufferLength, '0CcS'); + dataBuffer = ExAllocatePoolZero(NonPagedPoolNx, + bufferLength, + '0CcS'); #endif if (dataBuffer == NULL) { @@ -2573,8 +2579,6 @@ NTSTATUS ClasspDeviceGetBlockLimitsVPDPage( blockLimits = (PVPD_BLOCK_LIMITS_PAGE)dataBuffer; - RtlZeroMemory(dataBuffer, allocationBufferLength); - if (FdoExtension->AdapterDescriptor->SrbType == SRB_TYPE_STORAGE_REQUEST_BLOCK) { #pragma prefast(suppress:26015, "InitializeStorageRequestBlock ensures buffer access is bounded") @@ -3305,9 +3309,15 @@ Return Value: // based platforms. We are taking the conservative approach here. // bufferLength = ALIGN_UP_BY(bufferLength,KeGetRecommendedSharedDataAlignment()); - buffer = (PUNMAP_LIST_HEADER)ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, bufferLength, CLASS_TAG_LB_PROVISIONING); + buffer = (PUNMAP_LIST_HEADER) + ExAllocatePoolZero(NonPagedPoolNxCacheAligned, + bufferLength, + CLASS_TAG_LB_PROVISIONING); #else - buffer = (PUNMAP_LIST_HEADER)ExAllocatePoolWithTag(NonPagedPoolNx, bufferLength, CLASS_TAG_LB_PROVISIONING); + buffer = (PUNMAP_LIST_HEADER) + ExAllocatePoolZero(NonPagedPoolNx, + bufferLength, + CLASS_TAG_LB_PROVISIONING); #endif if (buffer == NULL) { @@ -3315,8 +3325,6 @@ Return Value: goto Exit; } - RtlZeroMemory(buffer, bufferLength); - blockDescrPointer = &buffer->Descriptors[0]; allDataSetRangeFullyConverted = FALSE; @@ -4373,9 +4381,15 @@ Return Value: // based platforms. We are taking the conservative approach here. // lbaStatusSize = ALIGN_UP_BY(lbaStatusSize,KeGetRecommendedSharedDataAlignment()); - lbaStatusListHeader = (PLBA_STATUS_LIST_HEADER)ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, lbaStatusSize, CLASS_TAG_LB_PROVISIONING); + lbaStatusListHeader = (PLBA_STATUS_LIST_HEADER) + ExAllocatePoolZero(NonPagedPoolNxCacheAligned, + lbaStatusSize, + CLASS_TAG_LB_PROVISIONING); #else - lbaStatusListHeader = (PLBA_STATUS_LIST_HEADER)ExAllocatePoolWithTag(NonPagedPoolNx, lbaStatusSize, CLASS_TAG_LB_PROVISIONING); + lbaStatusListHeader = (PLBA_STATUS_LIST_HEADER) + ExAllocatePoolZero(NonPagedPoolNx, + lbaStatusSize, + CLASS_TAG_LB_PROVISIONING); #endif if (lbaStatusListHeader == NULL) @@ -5032,9 +5046,15 @@ Return Value: // based platforms. We are taking the conservative approach here. // logPageSize = ALIGN_UP_BY(logPageSize, KeGetRecommendedSharedDataAlignment()); - logPage = (PLOG_PAGE_LOGICAL_BLOCK_PROVISIONING)ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, logPageSize, CLASS_TAG_LB_PROVISIONING); + logPage = (PLOG_PAGE_LOGICAL_BLOCK_PROVISIONING) + ExAllocatePoolZero(NonPagedPoolNxCacheAligned, + logPageSize, + CLASS_TAG_LB_PROVISIONING); #else - logPage = (PLOG_PAGE_LOGICAL_BLOCK_PROVISIONING)ExAllocatePoolWithTag(NonPagedPoolNx, logPageSize, CLASS_TAG_LB_PROVISIONING); + logPage = (PLOG_PAGE_LOGICAL_BLOCK_PROVISIONING) + ExAllocatePoolZero(NonPagedPoolNx, + logPageSize, + CLASS_TAG_LB_PROVISIONING); #endif if (logPage != NULL) { @@ -5166,9 +5186,9 @@ Arguments: srbSize = sizeof(SCSI_REQUEST_BLOCK); } - srb = ExAllocatePoolWithTag(NonPagedPoolNx, - srbSize, - 'ACcS'); + srb = ExAllocatePoolZero(NonPagedPoolNx, + srbSize, + 'ACcS'); if (srb != NULL) { // @@ -6046,7 +6066,9 @@ Arguments: } if (SenseBufferSize) { - senseData = ExAllocatePoolWithTag(NonPagedPoolNx, SenseBufferSize, CLASSPNP_POOL_TAG_LOG_MESSAGE); + senseData = ExAllocatePoolZero(NonPagedPoolNx, + SenseBufferSize, + CLASSPNP_POOL_TAG_LOG_MESSAGE); if (senseData) { senseBufferSize = SenseBufferSize; } @@ -6070,7 +6092,11 @@ Arguments: PIO_RETRIED_LOG_MESSAGE_CONTEXT ioLogMessageContext = NULL; - ioLogMessageContext = ExAllocatePoolWithTag(NonPagedPoolNx, sizeof(IO_RETRIED_LOG_MESSAGE_CONTEXT), CLASSPNP_POOL_TAG_LOG_MESSAGE); + ioLogMessageContext = + ExAllocatePoolZero(NonPagedPoolNx, + sizeof(IO_RETRIED_LOG_MESSAGE_CONTEXT), + CLASSPNP_POOL_TAG_LOG_MESSAGE); + if (!ioLogMessageContext) { goto __ClasspQueueLogIOEventWithContextWorker_ExitWithMessage; } @@ -7756,7 +7782,9 @@ Return Value: // // Allocate the buffer. // - buffer = ExAllocatePoolWithTag(NonPagedPoolNx, actualLength, CLASSPNP_POOL_TAG_TOKEN_OPERATION); + buffer = ExAllocatePoolZero(NonPagedPoolNx, + actualLength, + CLASSPNP_POOL_TAG_TOKEN_OPERATION); if (!buffer) { TracePrint((TRACE_LEVEL_ERROR, @@ -7768,8 +7796,6 @@ Return Value: goto __ClasspBinaryToAscii_Exit; } - RtlZeroMemory(buffer, actualLength); - for (i = 0, j = 0; i < Length; i++) { // @@ -7941,17 +7967,15 @@ Return Value: PMODE_CONTROL_PAGE pageData = NULL; ULONG size = 0; - modeData = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, - MODE_PAGE_DATA_SIZE, - CLASS_TAG_MODE_DATA); + modeData = ExAllocatePoolZero(NonPagedPoolNxCacheAligned, + MODE_PAGE_DATA_SIZE, + CLASS_TAG_MODE_DATA); if (modeData == NULL) { TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_SCSI, "ClasspZeroQERR: Unable to allocate mode data buffer\n")); goto ClasspZeroQERR_Exit; } - RtlZeroMemory(modeData, MODE_PAGE_DATA_SIZE); - size = ClassModeSense(DeviceObject, (PCHAR) modeData, MODE_PAGE_DATA_SIZE, @@ -8192,15 +8216,15 @@ ClasspGetHwFirmwareInfo( // retry: - firmwareInfo = ExAllocatePoolWithTag(NonPagedPoolNx, dataLength, CLASSPNP_POOL_TAG_FIRMWARE); + firmwareInfo = ExAllocatePoolZero(NonPagedPoolNx, + dataLength, + CLASSPNP_POOL_TAG_FIRMWARE); if (firmwareInfo == NULL) { TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_INIT, "ClasspGetHwFirmwareInfo: cannot allocate memory to hold data. \n")); return STATUS_INSUFFICIENT_RESOURCES; } - RtlZeroMemory(firmwareInfo, dataLength); - // // Set up query data, making sure the "Flags" field indicating the request is for device itself. // @@ -8705,15 +8729,15 @@ ClassDeviceHwFirmwareDownloadProcess( lockHeld = FALSE; #pragma prefast(suppress:6014, "The allocated memory that firmwareImageBuffer points to will be freed in ClassHwFirmwareDownloadComplete().") - firmwareImageBuffer = ExAllocatePoolWithTag(NonPagedPoolNx, bufferSize, CLASSPNP_POOL_TAG_FIRMWARE); + firmwareImageBuffer = ExAllocatePoolZero(NonPagedPoolNx, + bufferSize, + CLASSPNP_POOL_TAG_FIRMWARE); if (firmwareImageBuffer == NULL) { status = STATUS_INSUFFICIENT_RESOURCES; goto Exit_Firmware_Download; } - RtlZeroMemory(firmwareImageBuffer, bufferSize); - RtlCopyMemory(firmwareImageBuffer, firmwareDownload->ImageBuffer, (ULONG)firmwareDownload->BufferSize); } else { diff --git a/storage/class/classpnp/src/xferpkt.c b/storage/class/classpnp/src/xferpkt.c index 29019140..75300c9a 100644 --- a/storage/class/classpnp/src/xferpkt.c +++ b/storage/class/classpnp/src/xferpkt.c @@ -77,9 +77,9 @@ NTSTATUS InitializeTransferPackets(PDEVICE_OBJECT Fdo) // arraySize = KeQueryHighestNodeNumber() + 1; fdoData->FreeTransferPacketsLists = - ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, - sizeof(PNL_SLIST_HEADER) * arraySize, - CLASS_TAG_PRIVATE_DATA); + ExAllocatePoolZero(NonPagedPoolNxCacheAligned, + sizeof(PNL_SLIST_HEADER) * arraySize, + CLASS_TAG_PRIVATE_DATA); if (fdoData->FreeTransferPacketsLists == NULL) { status = STATUS_INSUFFICIENT_RESOURCES; @@ -264,11 +264,12 @@ NTSTATUS InitializeTransferPackets(PDEVICE_OBJECT Fdo) NT_ASSERT(FALSE); } } else { - fdoData->SrbTemplate = ExAllocatePoolWithTag(NonPagedPoolNx, sizeof(SCSI_REQUEST_BLOCK), '-brs'); + fdoData->SrbTemplate = ExAllocatePoolZero(NonPagedPoolNx, + sizeof(SCSI_REQUEST_BLOCK), + '-brs'); if (fdoData->SrbTemplate == NULL) { status = STATUS_INSUFFICIENT_RESOURCES; } else { - RtlZeroMemory(fdoData->SrbTemplate, sizeof(SCSI_REQUEST_BLOCK)); fdoData->SrbTemplate->Length = sizeof(SCSI_REQUEST_BLOCK); fdoData->SrbTemplate->Function = SRB_FUNCTION_EXECUTE_SCSI; } @@ -342,47 +343,51 @@ PTRANSFER_PACKET NewTransferPacket(PDEVICE_OBJECT Fdo) * Allocate the actual packet. */ if (NT_SUCCESS(status)) { - newPkt = ExAllocatePoolWithTag(NonPagedPoolNx, sizeof(TRANSFER_PACKET), 'pnPC'); + newPkt = ExAllocatePoolZero(NonPagedPoolNx, + sizeof(TRANSFER_PACKET), + 'pnPC'); if (newPkt == NULL) { TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_RW, "Failed to allocate transfer packet.")); status = STATUS_INSUFFICIENT_RESOURCES; } else { - RtlZeroMemory(newPkt, sizeof(TRANSFER_PACKET)); newPkt->AllocateNode = KeGetCurrentNodeNumber(); if (fdoExt->AdapterDescriptor->SrbType == SRB_TYPE_STORAGE_REQUEST_BLOCK) { #if (NTDDI_VERSION >= NTDDI_WINBLUE) if ((fdoExt->MiniportDescriptor != NULL) && (fdoExt->MiniportDescriptor->Size >= RTL_SIZEOF_THROUGH_FIELD(STORAGE_MINIPORT_DESCRIPTOR, ExtraIoInfoSupported)) && (fdoExt->MiniportDescriptor->ExtraIoInfoSupported == TRUE)) { - status = CreateStorageRequestBlock((PSTORAGE_REQUEST_BLOCK *)&newPkt->Srb, - fdoExt->AdapterDescriptor->AddressType, - DefaultStorageRequestBlockAllocateRoutine, - NULL, - 2, - SrbExDataTypeScsiCdb16, - SrbExDataTypeIoInfo - ); + + status = CreateStorageRequestBlock( + (PSTORAGE_REQUEST_BLOCK *)&newPkt->Srb, + fdoExt->AdapterDescriptor->AddressType, + DefaultStorageRequestBlockAllocateRoutine, + NULL, + 2, + SrbExDataTypeScsiCdb16, + SrbExDataTypeIoInfo); } else { - status = CreateStorageRequestBlock((PSTORAGE_REQUEST_BLOCK *)&newPkt->Srb, - fdoExt->AdapterDescriptor->AddressType, - DefaultStorageRequestBlockAllocateRoutine, - NULL, - 1, - SrbExDataTypeScsiCdb16 - ); + status = CreateStorageRequestBlock( + (PSTORAGE_REQUEST_BLOCK *)&newPkt->Srb, + fdoExt->AdapterDescriptor->AddressType, + DefaultStorageRequestBlockAllocateRoutine, + NULL, + 1, + SrbExDataTypeScsiCdb16); } #else - status = CreateStorageRequestBlock((PSTORAGE_REQUEST_BLOCK *)&newPkt->Srb, - fdoExt->AdapterDescriptor->AddressType, - DefaultStorageRequestBlockAllocateRoutine, - NULL, - 1, - SrbExDataTypeScsiCdb16 - ); + status = CreateStorageRequestBlock( + (PSTORAGE_REQUEST_BLOCK *)&newPkt->Srb, + fdoExt->AdapterDescriptor->AddressType, + DefaultStorageRequestBlockAllocateRoutine, + NULL, + 1, + SrbExDataTypeScsiCdb16); #endif } else { #pragma prefast(suppress:6014, "The allocated memory that Pkt->Srb points to will be freed in DestroyTransferPacket().") - newPkt->Srb = ExAllocatePoolWithTag(NonPagedPoolNx, sizeof(SCSI_REQUEST_BLOCK), '-brs'); + newPkt->Srb = ExAllocatePoolZero(NonPagedPoolNx, + sizeof(SCSI_REQUEST_BLOCK), + '-brs'); if (newPkt->Srb == NULL) { status = STATUS_INSUFFICIENT_RESOURCES; } @@ -447,7 +452,9 @@ PTRANSFER_PACKET NewTransferPacket(PDEVICE_OBJECT Fdo) historyByteCount = sizeof(SRB_HISTORY_ITEM) * fdoData->InterpretSenseInfo->HistoryCount; historyByteCount += sizeof(SRB_HISTORY) - sizeof(SRB_HISTORY_ITEM); - newPkt->RetryHistory = (PSRB_HISTORY)ExAllocatePoolWithTag(NonPagedPoolNx, historyByteCount, 'hrPC'); + newPkt->RetryHistory = (PSRB_HISTORY)ExAllocatePoolZero(NonPagedPoolNx, + historyByteCount, + 'hrPC'); if (newPkt->RetryHistory == NULL) { TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_RW, "Failed to allocate MDL for transfer packet.")); |
