[USBSTOR] Do not leak fields of DeviceExtensions upon device removal
[reactos.git] / drivers / usb / usbstor / pdo.c
index 93caca4..9a84483 100644 (file)
@@ -575,6 +575,10 @@ USBSTOR_PdoHandlePnp(
                bDelete = FALSE;
            }
 
+           // clean up the device extension
+           ASSERT(DeviceExtension->InquiryData);
+           ExFreePoolWithTag(DeviceExtension->InquiryData, USB_STOR_TAG);
+
            Irp->IoStatus.Status = STATUS_SUCCESS;
            IoCompleteRequest(Irp, IO_NO_INCREMENT);
 
@@ -658,7 +662,7 @@ USBSTOR_SyncCompletionRoutine(
 
 /*
 * @name USBSTOR_SendInternalCdb
-* 
+*
 * Issues an internal SCSI request to device.
 * The request is sent in a synchronous way.
 */
@@ -897,7 +901,7 @@ USBSTOR_CreatePDO(
         return Status;
     }
 
-    if (PDODeviceExtension->InquiryData->DeviceType == DIRECT_ACCESS_DEVICE)
+    if (PDODeviceExtension->InquiryData->DeviceType == DIRECT_ACCESS_DEVICE || PDODeviceExtension->InquiryData->DeviceType == READ_ONLY_DIRECT_ACCESS_DEVICE)
     {
         PDODeviceExtension->IsFloppy = FALSE; // TODO: implement the actual check
     }