@@ -676,6 +676,11 @@ static uint8_t USBD_CDC_RNDIS_Setup(USBD_HandleTypeDef *pdev,
676676 uint16_t status_info = 0U ;
677677 USBD_StatusTypeDef ret = USBD_OK ;
678678
679+ if (hcdc == NULL )
680+ {
681+ return (uint8_t )USBD_FAIL ;
682+ }
683+
679684 switch (req -> bmRequest & USB_REQ_TYPE_MASK )
680685 {
681686 case USB_REQ_TYPE_CLASS :
@@ -912,6 +917,11 @@ static uint8_t USBD_CDC_RNDIS_EP0_RxReady(USBD_HandleTypeDef *pdev)
912917{
913918 USBD_CDC_RNDIS_HandleTypeDef * hcdc = (USBD_CDC_RNDIS_HandleTypeDef * )pdev -> pClassData ;
914919
920+ if (hcdc == NULL )
921+ {
922+ return (uint8_t )USBD_FAIL ;
923+ }
924+
915925 if ((pdev -> pUserData != NULL ) && (hcdc -> CmdOpCode != 0xFFU ))
916926 {
917927 /* Check if the received command is SendEncapsulated command */
@@ -1048,6 +1058,11 @@ uint8_t USBD_CDC_RNDIS_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff, uin
10481058{
10491059 USBD_CDC_RNDIS_HandleTypeDef * hcdc = (USBD_CDC_RNDIS_HandleTypeDef * )pdev -> pClassData ;
10501060
1061+ if (hcdc == NULL )
1062+ {
1063+ return (uint8_t )USBD_FAIL ;
1064+ }
1065+
10511066 hcdc -> TxBuffer = pbuff ;
10521067 hcdc -> TxLength = length ;
10531068
@@ -1065,6 +1080,11 @@ uint8_t USBD_CDC_RNDIS_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff)
10651080{
10661081 USBD_CDC_RNDIS_HandleTypeDef * hcdc = (USBD_CDC_RNDIS_HandleTypeDef * )pdev -> pClassData ;
10671082
1083+ if (hcdc == NULL )
1084+ {
1085+ return (uint8_t )USBD_FAIL ;
1086+ }
1087+
10681088 hcdc -> RxBuffer = pbuff ;
10691089
10701090 return (uint8_t )USBD_OK ;
@@ -1168,6 +1188,11 @@ uint8_t USBD_CDC_RNDIS_SendNotification(USBD_HandleTypeDef *pdev,
11681188 UNUSED (bVal );
11691189 UNUSED (pData );
11701190
1191+ if (hcdc == NULL )
1192+ {
1193+ return (uint8_t )USBD_FAIL ;
1194+ }
1195+
11711196 /* Initialize the request fields */
11721197 (hcdc -> Req ).bmRequest = CDC_RNDIS_BMREQUEST_TYPE_RNDIS ;
11731198 (hcdc -> Req ).bRequest = (uint8_t )Notif ;
@@ -1280,6 +1305,11 @@ static uint8_t USBD_CDC_RNDIS_ProcessInitMsg(USBD_HandleTypeDef *pdev,
12801305 /* Store the Message Request ID */
12811306 uint32_t ReqId = InitMessage -> ReqId ;
12821307
1308+ if (hcdc == NULL )
1309+ {
1310+ return (uint8_t )USBD_FAIL ;
1311+ }
1312+
12831313 /* Check correctness of the message (MsgType already checked by entry to this function) */
12841314 if ((InitMessage -> MsgLength != sizeof (USBD_CDC_RNDIS_InitMsgTypeDef )) || \
12851315 (InitMessage -> MajorVersion < CDC_RNDIS_VERSION_MAJOR ))
@@ -1331,6 +1361,11 @@ static uint8_t USBD_CDC_RNDIS_ProcessHaltMsg(USBD_HandleTypeDef *pdev,
13311361 /* Get the CDC_RNDIS handle pointer */
13321362 USBD_CDC_RNDIS_HandleTypeDef * hcdc = (USBD_CDC_RNDIS_HandleTypeDef * )pdev -> pClassData ;
13331363
1364+ if (hcdc == NULL )
1365+ {
1366+ return (uint8_t )USBD_FAIL ;
1367+ }
1368+
13341369 /* Set CDC_RNDIS state to INITIALIZED */
13351370 hcdc -> State = CDC_RNDIS_STATE_UNINITIALIZED ;
13361371
@@ -1361,6 +1396,11 @@ static uint8_t USBD_CDC_RNDIS_ProcessKeepAliveMsg(USBD_HandleTypeDef *pdev,
13611396 /* Store the Message Request ID */
13621397 uint32_t ReqId = Msg -> ReqId ;
13631398
1399+ if (hcdc == NULL )
1400+ {
1401+ return (uint8_t )USBD_FAIL ;
1402+ }
1403+
13641404 /* Check correctness of the message (MsgType already checked by entry to this function) */
13651405 if (Msg -> MsgLength != sizeof (USBD_CDC_RNDIS_KpAliveMsgTypeDef ))
13661406 {
@@ -1406,6 +1446,11 @@ static uint8_t USBD_CDC_RNDIS_ProcessQueryMsg(USBD_HandleTypeDef *pdev,
14061446 /* Store the Message Request ID */
14071447 uint32_t ReqId = Msg -> RequestId ;
14081448
1449+ if (hcdc == NULL )
1450+ {
1451+ return (uint8_t )USBD_FAIL ;
1452+ }
1453+
14091454 /* Process the OID depending on its code */
14101455 switch (Msg -> Oid )
14111456 {
@@ -1549,6 +1594,11 @@ static uint8_t USBD_CDC_RNDIS_ProcessSetMsg(USBD_HandleTypeDef *pdev,
15491594 /* Store the Message Request ID */
15501595 uint32_t ReqId = SetMessage -> ReqId ;
15511596
1597+ if (hcdc == NULL )
1598+ {
1599+ return (uint8_t )USBD_FAIL ;
1600+ }
1601+
15521602 switch (SetMessage -> Oid )
15531603 {
15541604 case OID_GEN_CURRENT_PACKET_FILTER :
@@ -1600,6 +1650,11 @@ static uint8_t USBD_CDC_RNDIS_ProcessResetMsg(USBD_HandleTypeDef *pdev,
16001650 /* Use same Msg input buffer as response buffer */
16011651 USBD_CDC_RNDIS_ResetCpltMsgTypeDef * ResetResponse = (USBD_CDC_RNDIS_ResetCpltMsgTypeDef * )(void * )Msg ;
16021652
1653+ if (hcdc == NULL )
1654+ {
1655+ return (uint8_t )USBD_FAIL ;
1656+ }
1657+
16031658 if ((ResetMessage -> MsgLength != sizeof (USBD_CDC_RNDIS_ResetMsgTypeDef )) || \
16041659 (ResetMessage -> Reserved != 0U ))
16051660 {
@@ -1647,6 +1702,11 @@ static uint8_t USBD_CDC_RNDIS_ProcessPacketMsg(USBD_HandleTypeDef *pdev,
16471702 /* Get and format the Msg input */
16481703 USBD_CDC_RNDIS_PacketMsgTypeDef * PacketMsg = (USBD_CDC_RNDIS_PacketMsgTypeDef * )Msg ;
16491704
1705+ if (hcdc == NULL )
1706+ {
1707+ return (uint8_t )USBD_FAIL ;
1708+ }
1709+
16501710 /* Check correctness of the message */
16511711 if ((PacketMsg -> MsgType != CDC_RNDIS_PACKET_MSG_ID ))
16521712 {
@@ -1684,6 +1744,11 @@ static uint8_t USBD_CDC_RNDIS_ProcessUnsupportedMsg(USBD_HandleTypeDef *pdev,
16841744 /* Use same Msg input buffer as response buffer */
16851745 USBD_CDC_RNDIS_StsChangeMsgTypeDef * Response = (USBD_CDC_RNDIS_StsChangeMsgTypeDef * )(void * )Msg ;
16861746
1747+ if (hcdc == NULL )
1748+ {
1749+ return (uint8_t )USBD_FAIL ;
1750+ }
1751+
16871752 /* Setup the response buffer content */
16881753 Response -> MsgType = CDC_RNDIS_INDICATE_STATUS_MSG_ID ;
16891754 Response -> MsgLength = sizeof (USBD_CDC_RNDIS_StsChangeMsgTypeDef );
0 commit comments