[USBSTOR]
[reactos.git] / reactos / drivers / usb / usbstor / pdo.c
index 22157bc..d684ef3 100644 (file)
@@ -40,7 +40,7 @@ USBSTOR_GetDeviceType(
 
     //
     // FIXME: use constant - derived from http://en.wikipedia.org/wiki/SCSI_Peripheral_Device_Type
-    // 
+    //
     switch (InquiryData->DeviceType)
     {
         case 1:
@@ -114,7 +114,7 @@ USBSTOR_GetGenericType(
 
     //
     // FIXME: use constant - derived from http://en.wikipedia.org/wiki/SCSI_Peripheral_Device_Type
-    // 
+    //
     switch (InquiryData->DeviceType)
     {
         case 1:
@@ -628,7 +628,7 @@ USBSTOR_PdoHandleQueryCompatibleId(
         Irp->IoStatus.Information = 0;
         return STATUS_INSUFFICIENT_RESOURCES;
     }
+
     USBSTOR_ConvertToUnicodeString(Buffer, Length, 0, InstanceId, &Offset);
     USBSTOR_ConvertToUnicodeString(&Buffer[Offset], Length, Offset, InstanceId, &Offset);
 
@@ -701,7 +701,7 @@ USBSTOR_PdoHandleQueryInstanceId(
         Irp->IoStatus.Information = 0;
         return STATUS_INSUFFICIENT_RESOURCES;
     }
+
     //
     // copy instance id
     //
@@ -1041,7 +1041,7 @@ USBSTOR_AllocateIrp(
     Request->DataBuffer = ExAllocatePoolWithTag(NonPagedPool,
                                                 DataTransferLength,
                                                 USB_STOR_TAG);
-    if (!Request)
+    if (!Request->DataBuffer)
     {
         //
         // no memory
@@ -1061,6 +1061,7 @@ USBSTOR_AllocateIrp(
         // no memory
         //
         IoFreeIrp(Irp);
+        ExFreePoolWithTag(Request->DataBuffer, USB_STOR_TAG);
         ExFreePoolWithTag(Request, USB_STOR_TAG);
         return STATUS_INSUFFICIENT_RESOURCES;
     }
@@ -1169,6 +1170,14 @@ USBSTOR_SendIrp(
         //
         *OutData = Request->DataBuffer;
     }
+    else
+    {
+        //
+        // free the data
+        //
+        ExFreePoolWithTag(Request->DataBuffer, USB_STOR_TAG);
+        *OutData = NULL;
+    }
 
     //
     // free resources
@@ -1213,7 +1222,7 @@ USBSTOR_SendInquiryIrp(
     DPRINT1("Reserved %p\n", Response->Reserved);
     DPRINT1("Vendor %c%c%c%c%c%c%c%c\n", Response->Vendor[0], Response->Vendor[1], Response->Vendor[2], Response->Vendor[3], Response->Vendor[4], Response->Vendor[5], Response->Vendor[6], Response->Vendor[7]);
     DPRINT1("Product %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n", Response->Product[0], Response->Product[1], Response->Product[2], Response->Product[3],
-                                                          Response->Product[4], Response->Product[5], Response->Product[6], Response->Product[7], 
+                                                          Response->Product[4], Response->Product[5], Response->Product[6], Response->Product[7],
                                                           Response->Product[8], Response->Product[9], Response->Product[10], Response->Product[11],
                                                           Response->Product[12], Response->Product[13], Response->Product[14], Response->Product[15]);