Skip to main content
Visitor II
October 2, 2026
Question

found USB MSC library bug

  • October 2, 2026
  • 1 reply
  • 14 views

in “usbd_msc_scsi.c” at function “SCSI_ModeSense6”
/* Check If media is write-protected */

  if (((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->IsWriteProtected(lun) != 0)

  {

    MSC_Mode_Sense6_data[2] |= (0x1U << 7); /* Set the WP (write protection) bit */

  }

  else

  {

    MSC_Mode_Sense10_data[2] &= ~(0x1U << 7); /* Clear the WP (write protection) bit */

  }


is writing to the wrong place !!!   
Change it to:
MSC_Mode_Sense6_data[2] &= ~(0x1U << 7); /* Clear the WP (write protection) bit */

Note:
The wrong write mainly cause the write protection to stay on if its once set and never be able to unset without reseting the scsi device.

Took me days to track down this bug !!

 
best regards,
Labmaster
 

1 reply

Pavel A.
October 2, 2026