More anomalous code fragments in the USB 5.0 stack

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

More anomalous code fragments in the USB 5.0 stack

1,037件の閲覧回数
johnstrohm
Contributor III

This shows up in several places, most severely in usb_phdc.c, at lines 844-849.

    devicePtr->user_handle = *phdcHandle;

    #if USB_METADATA_SUPPORTED  

    devicePtr->phdc_metadata = FALSE; /* metadata feature disabled */

    #endif

    *phdcHandle =(unsigned long)devicePtr;

phdcHandle is described as an OUT parameter, meaning that it points SOMEWHERE valid, but the contents are unlikely to be anything useful.  This means that the assignment at line 844 is likely to store garbage in a well-defined place.

If the two assignments are reversed in order, garbage is not stored.  Instead, devicePtr->user_handle points to itself, which does not seem particularly useful, since you would then have devicePtr->user_handle == devicePtr.

usb_hid.c has the assignments in reverse order, viz.,

    *hidHandle =(unsigned long)devicePtr;

    //devicePtr->user_handle = *hidHandle;

but the self-looper creation is commented out.

usb_audio.c has the assignments in reverse order, making the self-looper.

    *audioHandle =(uint32_t)devicePtr;

    devicePtr->user_handle = *audioHandle;

The other class drivers all define a user_handle field in their respective header files, but do not bother to assign anything to it.

This looks like something that could be cleaned up.

ラベル(2)
タグ(2)
4 返答(返信)

795件の閲覧回数
Kan_Li
NXP TechSupport
NXP TechSupport

Hi John,

I am sorry, but which version are you referring to? I just checked usb_phdc.c in KSDK 1.1, the line 844-849 is not what you mentioned above, so would you please help to clarify?

1.png


Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信

795件の閲覧回数
johnstrohm
Contributor III

USB_STACK_V5.0: USB Stack v5.0-Beta Freescale bare metal (no OS) USB Stack, freshly downloaded from USB Stack|Freescale


I just pulled a brand-new copy, and verified it.


The lines in question are about 70 lines down from where your version shows line 844.


0 件の賞賛
返信

795件の閲覧回数
Kan_Li
NXP TechSupport
NXP TechSupport

Hi John,

Thanks for reporting this! I have forwarded this question to our USB stack team, and will let you know when I have any more information!


Have a great day,

Kan

0 件の賞賛
返信

795件の閲覧回数
Kan_Li
NXP TechSupport
NXP TechSupport

Hi John,

I just got the feedback, and the software team told me The code of PHDC init is wrong, actually user_handle is obsolete and should not be used. so in the later version usb_handle will all be commented. Thanks for your reporting!


Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------