From d91564734dbd6ca8d1a658d447684e85e4a304c0 Mon Sep 17 00:00:00 2001 From: Stefan Ginsberg Date: Wed, 24 Sep 2008 16:37:35 +0000 Subject: [PATCH] - IopGetDiskInformation: Fail if we are out of memory instead of dereferencing null - Fix for Coverity error CID: 469 - Also fix a (potential) memory leak svn path=/trunk/; revision=36487 --- reactos/ntoskrnl/io/iomgr/arcname.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/io/iomgr/arcname.c b/reactos/ntoskrnl/io/iomgr/arcname.c index 6560a3d732f..bec6172b526 100644 --- a/reactos/ntoskrnl/io/iomgr/arcname.c +++ b/reactos/ntoskrnl/io/iomgr/arcname.c @@ -217,7 +217,12 @@ IopGetDiskInformation(IN ULONG i, PartitionBuffer = ExAllocatePoolWithTag(NonPagedPool, DiskGeometry.BytesPerSector, TAG_IO); - if (!PartitionBuffer) return FALSE; + if (!PartitionBuffer) + { + /* Try again */ + ExFreePoolWithTag(DriveLayout, TAG_FILE_SYSTEM); + return FALSE; + } /* Build an IRP to read the partition sector */ KeInitializeEvent(&Event, NotificationEvent, FALSE); @@ -228,6 +233,13 @@ IopGetDiskInformation(IN ULONG i, &PartitionOffset, &Event, &StatusBlock); + if (!Irp) + { + /* Try again */ + ExFreePoolWithTag(PartitionBuffer, TAG_IO); + ExFreePoolWithTag(DriveLayout, TAG_FILE_SYSTEM); + return FALSE; + } /* Call the driver and check if we have to wait */ Status = IoCallDriver(DeviceObject, Irp);