Question
USB MSC library - null pointers
Posted on July 11, 2016 at 08:28
In the file ''usbh_msc.c'' generated by CubeMX there seem to be various instances of null pointer dereferencing.
Many functions begin with this statement: MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData; which doesn't check whether pActiveClass is NULL. It seems that in some places the issue is quite harmless since there are other guards, like if(phost->gState == HOST_CLASS) in USBH_MSC_IsReady() Nevertheless, in other places the problem is there, and it exists even when harmless (e.g. if you catch null pointer dereferencing by MPU-disabling access to the address 0x00000000.) Is this a bug, or should the user code manually check for something, before calling functions like USBH_MSC_IsReady()? What are those checks?