cancel
Showing results for 
Search instead for 
Did you mean: 

STM32Cube_FW_F2_V1.1.0 question - bug ?

Taylor.Sean
Associate II
Posted on April 22, 2014 at 17:40

STM32Cube_FW_F2_V1.1.0\Middlewares\ST\STM32_USB_Host_Library\Core\Src\usbh_core.c

uint8_t  USBH_FindInterface(USBH_HandleTypeDef *phost, uint8_t Class, uint8_t SubClass, uint8_t Protocol)

{

  USBH_InterfaceDescTypeDef    *pif ;

  USBH_CfgDescTypeDef          *pcfg ;

  int8_t                        if_ix = 0;

  

  pif = (USBH_InterfaceDescTypeDef *)0;

  pcfg = &phost->device.CfgDesc;  

  

  if((pif->bInterfaceClass == 0xFF) &&(pif->bInterfaceSubClass == 0xFF) && (pif->bInterfaceProtocol == 0xFF))

  {

    return 0xFF;

  }

while (if_ix < USBH_MAX_NUM_INTERFACES)

  {

    pif = &pcfg->Itf_Desc[if_ix];

  <snipped>

  

Maybe I'm not understanding this, but it looks like the pointer pif is set to address 0 and then is immediately dereferenced in the if statement.  I can't see how this can possibly work.  

It looks to me like the if((pif->bInterfaceClass == 0xFF) might need to be inside the while() loop, right after pif is assigned the address of one of the interface descriptors.
1 REPLY 1
Posted on May 29, 2014 at 16:40

Hi,

This is a bug; the following statement should be removed:

if((pif->bInterfaceClass == 0xFF) &&(pif->bInterfaceSubClass == 0xFF) && (pif->bInterfaceProtocol == 0xFF))
{
return 0xFF;
}

With regards.