]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fixed a bug that the system hangs with an assert in DiskIo.c that is division overflo...
authorrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 23 Jul 2009 01:30:16 +0000 (01:30 +0000)
committerrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 23 Jul 2009 01:30:16 +0000 (01:30 +0000)
Root cause is that Read Capacity command returns media not present error, then UsbMassStorage driver issues Sense Request command to get the sense data. However, the USB floppy drive still returns the previous error for the Sense Request command. UsbBootRequestSense() does not handle this case correctly and returns EFI_SUCCESS so that the block size of the Block IO protocol instance is set to be 0.

Solution is to fix the logic to handle the case and add protective logic to avoid setting block size to be 0.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8979 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c

index 71deef051e39b666538f44f27fd576f4804712ee..013b7e2cc3c82b486f8d61e63f919fb22cdcedd3 100644 (file)
@@ -65,6 +65,9 @@ UsbBootRequestSense (
                         );\r
   if (EFI_ERROR (Status) || CmdResult != USB_MASS_CMD_SUCCESS) {\r
     DEBUG ((EFI_D_ERROR, "UsbBootRequestSense: (%r) CmdResult=0x%x\n", Status, CmdResult));\r
+    if (!EFI_ERROR (Status)) {\r
+      Status = EFI_DEVICE_ERROR;\r
+    }\r
     return Status;\r
   }\r
 \r
@@ -375,6 +378,7 @@ UsbBootReadCapacity (
   USB_BOOT_READ_CAPACITY_DATA CapacityData;\r
   EFI_BLOCK_IO_MEDIA          *Media;\r
   EFI_STATUS                  Status;\r
+  UINT32                      BlockSize;\r
 \r
   Media   = &UsbMass->BlockIoMedia;\r
 \r
@@ -403,10 +407,12 @@ UsbBootReadCapacity (
   //\r
   Media->MediaPresent = TRUE;\r
   Media->LastBlock    = SwapBytes32 (ReadUnaligned32 ((CONST UINT32 *) CapacityData.LastLba));\r
-  Media->BlockSize    = SwapBytes32 (ReadUnaligned32 ((CONST UINT32 *) CapacityData.BlockLen));\r
 \r
-  if (Media->BlockSize == 0) {\r
+  BlockSize           = SwapBytes32 (ReadUnaligned32 ((CONST UINT32 *) CapacityData.BlockLen));\r
+  if (BlockSize == 0) {\r
     return EFI_NOT_READY;\r
+  } else {\r
+    Media->BlockSize = BlockSize;\r
   }\r
 \r
   DEBUG ((EFI_D_INFO, "UsbBootReadCapacity Success LBA=%ld BlockSize=%d\n",\r