diff options
| author | dwimmel-msft <[email protected]> | 2022-05-04 11:03:57 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-05-04 11:03:57 -0700 |
| commit | a423bafcdcf7a58de7d3abd284f6107e4cce329f (patch) | |
| tree | a5fd33f061d96ad3151270816f4dcb4f3d86476c | |
| parent | 30f39e4a535b0b4bc7215fdeee6b6d3a0659a797 (diff) | |
[storage/class/disk] Use ExAllocatePool2 (#712)
| -rw-r--r-- | storage/class/disk/src/disk.c | 73 | ||||
| -rw-r--r-- | storage/class/disk/src/diskwmi.c | 19 | ||||
| -rw-r--r-- | storage/class/disk/src/enum.c | 12 | ||||
| -rw-r--r-- | storage/class/disk/src/geometry.c | 10 | ||||
| -rw-r--r-- | storage/class/disk/src/pnp.c | 4 |
5 files changed, 38 insertions, 80 deletions
diff --git a/storage/class/disk/src/disk.c b/storage/class/disk/src/disk.c index 2bfcb35d..c8dbeb59 100644 --- a/storage/class/disk/src/disk.c +++ b/storage/class/disk/src/disk.c @@ -1288,7 +1288,7 @@ Return Value: srbSize = sizeof(SCSI_REQUEST_BLOCK); } - srb = ExAllocatePoolWithTag(NonPagedPoolNx, + srb = ExAllocatePool2(POOL_FLAG_NON_PAGED, srbSize, DISK_TAG_SRB); if (srb == NULL) { @@ -1303,7 +1303,6 @@ Return Value: return(STATUS_INSUFFICIENT_RESOURCES); } - RtlZeroMemory(srb, srbSize); if (fdoExtension->AdapterDescriptor->SrbType == SRB_TYPE_STORAGE_REQUEST_BLOCK) { srbEx = (PSTORAGE_REQUEST_BLOCK)srb; @@ -1849,7 +1848,7 @@ Return Value: // Allocate buffer for mode select header, block descriptor, and mode page. // - buffer = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, + buffer = ExAllocatePool2(POOL_FLAG_NON_PAGED | POOL_FLAG_CACHE_ALIGNED, length2, DISK_TAG_MODE_DATA); @@ -1857,8 +1856,6 @@ Return Value: return STATUS_INSUFFICIENT_RESOURCES; } - RtlZeroMemory(buffer, length2); - // // Set length in header to size of mode page. // @@ -2719,7 +2716,7 @@ Return Value: // Allocate Srb from nonpaged pool. // - context = ExAllocatePoolWithTag(NonPagedPoolNx, + context = ExAllocatePool2(POOL_FLAG_NON_PAGED, sizeof(COMPLETION_CONTEXT), DISK_TAG_CCONTEXT); @@ -2739,12 +2736,6 @@ Return Value: srbEx = &context->Srb.SrbEx; // - // Zero out srb - // - - RtlZeroMemory(srbEx, sizeof(context->Srb.SrbExBuffer)); - - // // Set up STORAGE_REQUEST_BLOCK fields // @@ -2767,12 +2758,6 @@ Return Value: } else { // - // Zero out srb. - // - - RtlZeroMemory(srb, SCSI_REQUEST_BLOCK_SIZE); - - // // Write length to SRB. // @@ -2891,7 +2876,7 @@ DiskGetInfoExceptionInformation( // ReturnPageData is allocated by the caller // - modeData = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, + modeData = ExAllocatePool2(POOL_FLAG_NON_PAGED | POOL_FLAG_CACHE_ALIGNED, MODE_DATA_SIZE, DISK_TAG_INFO_EXCEPTION); @@ -2902,8 +2887,6 @@ DiskGetInfoExceptionInformation( return STATUS_INSUFFICIENT_RESOURCES; } - RtlZeroMemory(modeData, MODE_DATA_SIZE); - length = ClassModeSense(FdoExtension->DeviceObject, (PCHAR) modeData, MODE_DATA_SIZE, @@ -3031,7 +3014,7 @@ Return Value: - modeData = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, + modeData = ExAllocatePool2(POOL_FLAG_NON_PAGED | POOL_FLAG_CACHE_ALIGNED, MODE_DATA_SIZE, DISK_TAG_DISABLE_CACHE); @@ -3042,8 +3025,6 @@ Return Value: return STATUS_INSUFFICIENT_RESOURCES; } - RtlZeroMemory(modeData, MODE_DATA_SIZE); - length = ClassModeSense(FdoExtension->DeviceObject, (PCHAR) modeData, MODE_DATA_SIZE, @@ -3175,7 +3156,7 @@ Return Value: PAGED_CODE(); - modeData = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, + modeData = ExAllocatePool2(POOL_FLAG_NON_PAGED | POOL_FLAG_CACHE_ALIGNED, MODE_DATA_SIZE, DISK_TAG_DISABLE_CACHE); @@ -3186,8 +3167,6 @@ Return Value: return STATUS_INSUFFICIENT_RESOURCES; } - RtlZeroMemory(modeData, MODE_DATA_SIZE); - length = ClassModeSense(FdoExtension->DeviceObject, (PCHAR) modeData, MODE_DATA_SIZE, @@ -4041,7 +4020,7 @@ Return Value: srbSize = SCSI_REQUEST_BLOCK_SIZE; } - srb = ExAllocatePoolWithTag(NonPagedPoolNx, + srb = ExAllocatePool2(POOL_FLAG_NON_PAGED, srbSize, DISK_TAG_SRB); @@ -4050,8 +4029,6 @@ Return Value: return STATUS_INSUFFICIENT_RESOURCES; } - RtlZeroMemory(srb, srbSize); - // // Send a TUR to determine if media is present. // @@ -4133,7 +4110,7 @@ Return Value: } modeLength = MODE_DATA_SIZE; - modeData = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, + modeData = ExAllocatePool2(POOL_FLAG_NON_PAGED | POOL_FLAG_CACHE_ALIGNED, modeLength, DISK_TAG_MODE_DATA); @@ -4143,8 +4120,6 @@ Return Value: return STATUS_INSUFFICIENT_RESOURCES; } - RtlZeroMemory(modeData, modeLength); - // // Build the MODE SENSE CDB using previous SRB. // @@ -4329,7 +4304,7 @@ Return Value: // readBufferSize = fdoExtension->DiskGeometry.BytesPerSector; - readBuffer = ExAllocatePoolWithTag(NonPagedPoolNx, + readBuffer = ExAllocatePool2(POOL_FLAG_NON_PAGED, readBufferSize, DISK_TAG_SMART); @@ -4553,7 +4528,7 @@ Return Value: } else { srbSize = SCSI_REQUEST_BLOCK_SIZE; } - srb = ExAllocatePoolWithTag(NonPagedPoolNx, + srb = ExAllocatePool2(POOL_FLAG_NON_PAGED, srbSize, DISK_TAG_SRB); @@ -4562,8 +4537,6 @@ Return Value: return STATUS_INSUFFICIENT_RESOURCES; } - RtlZeroMemory(srb, srbSize); - // // Add disk offset to starting sector. // @@ -4593,7 +4566,7 @@ Return Value: } } - Context = ExAllocatePoolWithTag(NonPagedPoolNx, + Context = ExAllocatePool2(POOL_FLAG_NON_PAGED, sizeof(DISK_VERIFY_WORKITEM_CONTEXT), DISK_TAG_WI_CONTEXT); if (Context) { @@ -4705,7 +4678,7 @@ Return Value: } else { srbSize = SCSI_REQUEST_BLOCK_SIZE; } - srb = ExAllocatePoolWithTag(NonPagedPoolNx, + srb = ExAllocatePool2(POOL_FLAG_NON_PAGED, srbSize, DISK_TAG_SRB); @@ -4714,8 +4687,6 @@ Return Value: return STATUS_INSUFFICIENT_RESOURCES; } - RtlZeroMemory(srb, srbSize); - // // Build the data buffer to be transferred in the input buffer. // The format of the data to the device is: @@ -4912,7 +4883,7 @@ Return Value: } else { srbSize = SCSI_REQUEST_BLOCK_SIZE; } - srb = ExAllocatePoolWithTag(NonPagedPoolNx, + srb = ExAllocatePool2(POOL_FLAG_NON_PAGED, srbSize, DISK_TAG_SRB); @@ -4921,8 +4892,6 @@ Return Value: return STATUS_INSUFFICIENT_RESOURCES; } - RtlZeroMemory(srb, srbSize); - // // Build the data buffer to be transferred in the input buffer. // The format of the data to the device is: @@ -5098,7 +5067,7 @@ Return Value: } else { srbSize = SCSI_REQUEST_BLOCK_SIZE; } - srb = ExAllocatePoolWithTag(NonPagedPoolNx, + srb = ExAllocatePool2(POOL_FLAG_NON_PAGED, srbSize, DISK_TAG_SRB); @@ -5107,8 +5076,6 @@ Return Value: return STATUS_INSUFFICIENT_RESOURCES; } - RtlZeroMemory(srb, srbSize); - // // Allocate memory for a mode header and then some // for port drivers that need to convert to MODE10 @@ -5117,7 +5084,7 @@ Return Value: // modeLength = MODE_DATA_SIZE; - modeData = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, + modeData = ExAllocatePool2(POOL_FLAG_NON_PAGED | POOL_FLAG_CACHE_ALIGNED, modeLength, DISK_TAG_MODE_DATA); @@ -5127,8 +5094,6 @@ Return Value: return STATUS_INSUFFICIENT_RESOURCES; } - RtlZeroMemory(modeData, modeLength); - // // Build the MODE SENSE CDB // @@ -5573,7 +5538,7 @@ Return Value: return STATUS_BUFFER_TOO_SMALL; } - srbControl = ExAllocatePoolWithTag(NonPagedPoolNx, + srbControl = ExAllocatePool2(POOL_FLAG_NON_PAGED, sizeof(SRB_IO_CONTROL) + sizeof(GETVERSIONINPARAMS), DISK_TAG_SMART); @@ -5583,8 +5548,6 @@ Return Value: return STATUS_INSUFFICIENT_RESOURCES; } - RtlZeroMemory(srbControl, sizeof(SRB_IO_CONTROL) + sizeof(GETVERSIONINPARAMS)); - // // fill in srbControl fields // @@ -5774,7 +5737,7 @@ Return Value: return STATUS_INVALID_PARAMETER; } - srbControl = ExAllocatePoolWithTag(NonPagedPoolNx, + srbControl = ExAllocatePool2(POOL_FLAG_NON_PAGED, sizeof(SRB_IO_CONTROL) + length, DISK_TAG_SMART); @@ -6032,7 +5995,7 @@ Return Value: } length += max(sizeof(SENDCMDOUTPARAMS), sizeof(SENDCMDINPARAMS)); - srbControl = ExAllocatePoolWithTag(NonPagedPoolNx, + srbControl = ExAllocatePool2(POOL_FLAG_NON_PAGED, sizeof(SRB_IO_CONTROL) + length, DISK_TAG_SMART); diff --git a/storage/class/disk/src/diskwmi.c b/storage/class/disk/src/diskwmi.c index c1a0945e..7503e5a1 100644 --- a/storage/class/disk/src/diskwmi.c +++ b/storage/class/disk/src/diskwmi.c @@ -393,7 +393,7 @@ DiskReadSmartLog( logSize = SectorCount * SMART_LOG_SECTOR_SIZE; bufferSize = sizeof(SRB_IO_CONTROL) + max( sizeof(SENDCMDINPARAMS), sizeof(SENDCMDOUTPARAMS) - 1 + logSize ); - srbControl = ExAllocatePoolWithTag(NonPagedPoolNx, + srbControl = ExAllocatePool2(POOL_FLAG_NON_PAGED, bufferSize, DISK_TAG_SMART); @@ -444,7 +444,7 @@ DiskWriteSmartLog( bufferSize = sizeof(SRB_IO_CONTROL) + sizeof(SENDCMDINPARAMS) - 1 + logSize; - srbControl = ExAllocatePoolWithTag(NonPagedPoolNx, + srbControl = ExAllocatePool2(POOL_FLAG_NON_PAGED, bufferSize, DISK_TAG_SMART); @@ -992,7 +992,7 @@ DiskEnableInfoExceptions( modeDataSize = MODE_DATA_SIZE; - modeData = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, + modeData = ExAllocatePool2(POOL_FLAG_NON_PAGED | POOL_FLAG_CACHE_ALIGNED, modeDataSize, DISK_TAG_INFO_EXCEPTION); @@ -1363,7 +1363,7 @@ Return Value: outBufferSize = sizeof(SRB_IO_CONTROL) + max( sizeof(SENDCMDINPARAMS), sizeof(SENDCMDOUTPARAMS) - 1 + READ_ATTRIBUTE_BUFFER_SIZE ); - outBuffer = ExAllocatePoolWithTag(NonPagedPoolNx, + outBuffer = ExAllocatePool2(POOL_FLAG_NON_PAGED, outBufferSize, DISK_TAG_SMART); @@ -1453,7 +1453,7 @@ Return Value: outBufferSize = sizeof(SRB_IO_CONTROL) + max( sizeof(SENDCMDINPARAMS), sizeof(SENDCMDOUTPARAMS) - 1 + READ_THRESHOLD_BUFFER_SIZE ); - outBuffer = ExAllocatePoolWithTag(NonPagedPoolNx, + outBuffer = ExAllocatePool2(POOL_FLAG_NON_PAGED, outBufferSize, DISK_TAG_SMART); @@ -1588,7 +1588,7 @@ DiskPostReregisterRequest( return STATUS_INSUFFICIENT_RESOURCES; } - reregRequest = ExAllocatePoolWithTag(NonPagedPoolNx, + reregRequest = ExAllocatePool2(POOL_FLAG_NON_PAGED, sizeof(DISKREREGREQUEST), DISK_TAG_SMART); if (reregRequest != NULL) @@ -1934,7 +1934,7 @@ DiskInfoExceptionCheck( PSTOR_ADDR_BTL8 storAddrBtl8 = NULL; PSRBEX_DATA_SCSI_CDB16 srbExDataCdb16 = NULL; - modeData = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, + modeData = ExAllocatePool2(POOL_FLAG_NON_PAGED | POOL_FLAG_CACHE_ALIGNED, MODE_DATA_SIZE, DISK_TAG_INFO_EXCEPTION); if (modeData == NULL) @@ -1949,7 +1949,7 @@ DiskInfoExceptionCheck( } else { srbSize = SCSI_REQUEST_BLOCK_SIZE; } - srb = ExAllocatePoolWithTag(NonPagedPoolNx, + srb = ExAllocatePool2(POOL_FLAG_NON_PAGED, srbSize, DISK_TAG_SRB); if (srb == NULL) @@ -1959,13 +1959,12 @@ DiskInfoExceptionCheck( "buffer\n")); return(STATUS_INSUFFICIENT_RESOURCES); } - RtlZeroMemory(srb, srbSize); // // Sense buffer is in aligned nonpaged pool. // - senseInfoBuffer = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, + senseInfoBuffer = ExAllocatePool2(POOL_FLAG_NON_PAGED | POOL_FLAG_CACHE_ALIGNED, SENSE_BUFFER_SIZE_EX, '7CcS'); diff --git a/storage/class/disk/src/enum.c b/storage/class/disk/src/enum.c index d5521caf..9ca58008 100644 --- a/storage/class/disk/src/enum.c +++ b/storage/class/disk/src/enum.c @@ -82,8 +82,8 @@ DiskConvertExtendedToLayout( return NULL; } - Layout = ExAllocatePoolWithTag ( - NonPagedPoolNx, + Layout = ExAllocatePool2 ( + POOL_FLAG_NON_PAGED, LayoutSize, DISK_TAG_PART_LIST ); @@ -214,8 +214,8 @@ Return Values: return NULL; } - layoutEx = ExAllocatePoolWithTag( - NonPagedPoolNx, + layoutEx = ExAllocatePool2( + POOL_FLAG_NON_PAGED, size, DISK_TAG_PART_LIST ); @@ -342,14 +342,12 @@ Return Value: partitionListSize = FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION_EX, PartitionEntry[1]); - partitionList = ExAllocatePoolWithTag(NonPagedPoolNx, + partitionList = ExAllocatePool2(POOL_FLAG_NON_PAGED, partitionListSize, DISK_TAG_PART_LIST); if (partitionList != NULL) { - RtlZeroMemory( partitionList, partitionListSize ); - // // Set the partition count to one and the status to success // so one device object will be created. Set the partition type diff --git a/storage/class/disk/src/geometry.c b/storage/class/disk/src/geometry.c index a852c092..7017ee82 100644 --- a/storage/class/disk/src/geometry.c +++ b/storage/class/disk/src/geometry.c @@ -328,7 +328,7 @@ DiskSaveGeometryDetectInfo( RtlInitUnicodeString(&unicodeString, L"Configuration Data"); - keyData = ExAllocatePoolWithTag(PagedPool, + keyData = ExAllocatePool2(POOL_FLAG_PAGED, VALUE_BUFFER_SIZE, DISK_TAG_UPDATE_GEOM); @@ -395,7 +395,7 @@ DiskSaveGeometryDetectInfo( // length = sizeof(DISK_DETECT_INFO) * numberOfDrives; - DetectInfoList = ExAllocatePoolWithTag(PagedPool, + DetectInfoList = ExAllocatePool2(POOL_FLAG_PAGED, length, DISK_TAG_UPDATE_GEOM); @@ -410,8 +410,6 @@ DiskSaveGeometryDetectInfo( DetectInfoCount = numberOfDrives; - RtlZeroMemory(DetectInfoList, length); - // // Copy the information out of the key data and into the list we've // allocated. @@ -660,7 +658,7 @@ Return Value: RtlInitUnicodeString(&unicodeString, L"Identifier"); - keyData = ExAllocatePoolWithTag(PagedPool, + keyData = ExAllocatePool2(POOL_FLAG_PAGED, VALUE_BUFFER_SIZE, DISK_TAG_UPDATE_GEOM); @@ -1140,7 +1138,7 @@ Routine Description: PAGED_CODE(); - readBuffer = ExAllocatePoolWithTag(NonPagedPoolNx, FdoExtension->DiskGeometry.BytesPerSector, DISK_TAG_UPDATE_GEOM); + readBuffer = ExAllocatePool2(POOL_FLAG_NON_PAGED, FdoExtension->DiskGeometry.BytesPerSector, DISK_TAG_UPDATE_GEOM); if (readBuffer) { diff --git a/storage/class/disk/src/pnp.c b/storage/class/disk/src/pnp.c index 5eb333e7..c1d3276f 100644 --- a/storage/class/disk/src/pnp.c +++ b/storage/class/disk/src/pnp.c @@ -281,7 +281,7 @@ Return Value: // Allocate request sense buffer. // - fdoExtension->SenseData = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned, + fdoExtension->SenseData = ExAllocatePool2(POOL_FLAG_NON_PAGED | POOL_FLAG_CACHE_ALIGNED, SENSE_BUFFER_SIZE_EX, DISK_TAG_START); @@ -642,7 +642,7 @@ Return Value: return status; } - *RawName = ExAllocatePoolWithTag(PagedPool, + *RawName = ExAllocatePool2(POOL_FLAG_PAGED, strlen(rawName) + 1, DISK_TAG_NAME); |
