[CDROM]
authorThomas Faber <thomas.faber@reactos.org>
Fri, 4 Sep 2015 16:01:46 +0000 (16:01 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Fri, 4 Sep 2015 16:01:46 +0000 (16:01 +0000)
- Avoid IRP leaks

svn path=/trunk/; revision=69003

reactos/drivers/storage/class/cdrom/cdrom.c

index e90825a..7629de0 100644 (file)
@@ -2139,7 +2139,6 @@ ScsiCdRomStartIo(
                     IoCompleteRequest(Irp, IO_DISK_INCREMENT);
                     ExFreePool(senseBuffer);
                     ExFreePool(srb);
                     IoCompleteRequest(Irp, IO_DISK_INCREMENT);
                     ExFreePool(senseBuffer);
                     ExFreePool(srb);
-                    IoFreeIrp(irp2);
                     IoStartNextPacket(DeviceObject, FALSE);
                     DebugPrint((2, "ScsiCdRomStartIo: [%lx] bailing with status %lx at line %s\n", Irp, Irp->IoStatus.Status, __LINE__));
                     return;
                     IoStartNextPacket(DeviceObject, FALSE);
                     DebugPrint((2, "ScsiCdRomStartIo: [%lx] bailing with status %lx at line %s\n", Irp, Irp->IoStatus.Status, __LINE__));
                     return;
@@ -2764,6 +2763,9 @@ ScsiCdRomStartIo(
             //
 
             IoCompleteRequest(Irp, IO_NO_INCREMENT);
             //
 
             IoCompleteRequest(Irp, IO_NO_INCREMENT);
+            ExFreePool(senseBuffer);
+            ExFreePool(srb);
+            IoFreeIrp(irp2);
             return;
 
         } // end switch()
             return;
 
         } // end switch()
@@ -2953,6 +2955,17 @@ CdRomDeviceControlCompletion(
                 (realIrpStack->MajorFunction == IRP_MJ_INTERNAL_DEVICE_CONTROL)) &&
                 (realIrpStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_CDROM_CHECK_VERIFY)) {
 
                 (realIrpStack->MajorFunction == IRP_MJ_INTERNAL_DEVICE_CONTROL)) &&
                 (realIrpStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_CDROM_CHECK_VERIFY)) {
 
+                ExFreePool(srb->SenseInfoBuffer);
+                if (srb->DataBuffer) {
+                    ExFreePool(srb->DataBuffer);
+                }
+                ExFreePool(srb);
+                if (Irp->MdlAddress) {
+                    IoFreeMdl(Irp->MdlAddress);
+                }
+
+                IoFreeIrp(Irp);
+
                 //
                 // Update the geometry information, as the media could have changed.
                 // The completion routine for this will complete the real irp and start
                 //
                 // Update the geometry information, as the media could have changed.
                 // The completion routine for this will complete the real irp and start