@@ -676,6 +676,11 @@ static uint8_t USBD_CDC_RNDIS_Setup(USBD_HandleTypeDef *pdev,
676
676
uint16_t status_info = 0U ;
677
677
USBD_StatusTypeDef ret = USBD_OK ;
678
678
679
+ if (hcdc == NULL )
680
+ {
681
+ return (uint8_t )USBD_FAIL ;
682
+ }
683
+
679
684
switch (req -> bmRequest & USB_REQ_TYPE_MASK )
680
685
{
681
686
case USB_REQ_TYPE_CLASS :
@@ -912,6 +917,11 @@ static uint8_t USBD_CDC_RNDIS_EP0_RxReady(USBD_HandleTypeDef *pdev)
912
917
{
913
918
USBD_CDC_RNDIS_HandleTypeDef * hcdc = (USBD_CDC_RNDIS_HandleTypeDef * )pdev -> pClassData ;
914
919
920
+ if (hcdc == NULL )
921
+ {
922
+ return (uint8_t )USBD_FAIL ;
923
+ }
924
+
915
925
if ((pdev -> pUserData != NULL ) && (hcdc -> CmdOpCode != 0xFFU ))
916
926
{
917
927
/* 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
1048
1058
{
1049
1059
USBD_CDC_RNDIS_HandleTypeDef * hcdc = (USBD_CDC_RNDIS_HandleTypeDef * )pdev -> pClassData ;
1050
1060
1061
+ if (hcdc == NULL )
1062
+ {
1063
+ return (uint8_t )USBD_FAIL ;
1064
+ }
1065
+
1051
1066
hcdc -> TxBuffer = pbuff ;
1052
1067
hcdc -> TxLength = length ;
1053
1068
@@ -1065,6 +1080,11 @@ uint8_t USBD_CDC_RNDIS_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff)
1065
1080
{
1066
1081
USBD_CDC_RNDIS_HandleTypeDef * hcdc = (USBD_CDC_RNDIS_HandleTypeDef * )pdev -> pClassData ;
1067
1082
1083
+ if (hcdc == NULL )
1084
+ {
1085
+ return (uint8_t )USBD_FAIL ;
1086
+ }
1087
+
1068
1088
hcdc -> RxBuffer = pbuff ;
1069
1089
1070
1090
return (uint8_t )USBD_OK ;
@@ -1168,6 +1188,11 @@ uint8_t USBD_CDC_RNDIS_SendNotification(USBD_HandleTypeDef *pdev,
1168
1188
UNUSED (bVal );
1169
1189
UNUSED (pData );
1170
1190
1191
+ if (hcdc == NULL )
1192
+ {
1193
+ return (uint8_t )USBD_FAIL ;
1194
+ }
1195
+
1171
1196
/* Initialize the request fields */
1172
1197
(hcdc -> Req ).bmRequest = CDC_RNDIS_BMREQUEST_TYPE_RNDIS ;
1173
1198
(hcdc -> Req ).bRequest = (uint8_t )Notif ;
@@ -1280,6 +1305,11 @@ static uint8_t USBD_CDC_RNDIS_ProcessInitMsg(USBD_HandleTypeDef *pdev,
1280
1305
/* Store the Message Request ID */
1281
1306
uint32_t ReqId = InitMessage -> ReqId ;
1282
1307
1308
+ if (hcdc == NULL )
1309
+ {
1310
+ return (uint8_t )USBD_FAIL ;
1311
+ }
1312
+
1283
1313
/* Check correctness of the message (MsgType already checked by entry to this function) */
1284
1314
if ((InitMessage -> MsgLength != sizeof (USBD_CDC_RNDIS_InitMsgTypeDef )) || \
1285
1315
(InitMessage -> MajorVersion < CDC_RNDIS_VERSION_MAJOR ))
@@ -1331,6 +1361,11 @@ static uint8_t USBD_CDC_RNDIS_ProcessHaltMsg(USBD_HandleTypeDef *pdev,
1331
1361
/* Get the CDC_RNDIS handle pointer */
1332
1362
USBD_CDC_RNDIS_HandleTypeDef * hcdc = (USBD_CDC_RNDIS_HandleTypeDef * )pdev -> pClassData ;
1333
1363
1364
+ if (hcdc == NULL )
1365
+ {
1366
+ return (uint8_t )USBD_FAIL ;
1367
+ }
1368
+
1334
1369
/* Set CDC_RNDIS state to INITIALIZED */
1335
1370
hcdc -> State = CDC_RNDIS_STATE_UNINITIALIZED ;
1336
1371
@@ -1361,6 +1396,11 @@ static uint8_t USBD_CDC_RNDIS_ProcessKeepAliveMsg(USBD_HandleTypeDef *pdev,
1361
1396
/* Store the Message Request ID */
1362
1397
uint32_t ReqId = Msg -> ReqId ;
1363
1398
1399
+ if (hcdc == NULL )
1400
+ {
1401
+ return (uint8_t )USBD_FAIL ;
1402
+ }
1403
+
1364
1404
/* Check correctness of the message (MsgType already checked by entry to this function) */
1365
1405
if (Msg -> MsgLength != sizeof (USBD_CDC_RNDIS_KpAliveMsgTypeDef ))
1366
1406
{
@@ -1406,6 +1446,11 @@ static uint8_t USBD_CDC_RNDIS_ProcessQueryMsg(USBD_HandleTypeDef *pdev,
1406
1446
/* Store the Message Request ID */
1407
1447
uint32_t ReqId = Msg -> RequestId ;
1408
1448
1449
+ if (hcdc == NULL )
1450
+ {
1451
+ return (uint8_t )USBD_FAIL ;
1452
+ }
1453
+
1409
1454
/* Process the OID depending on its code */
1410
1455
switch (Msg -> Oid )
1411
1456
{
@@ -1549,6 +1594,11 @@ static uint8_t USBD_CDC_RNDIS_ProcessSetMsg(USBD_HandleTypeDef *pdev,
1549
1594
/* Store the Message Request ID */
1550
1595
uint32_t ReqId = SetMessage -> ReqId ;
1551
1596
1597
+ if (hcdc == NULL )
1598
+ {
1599
+ return (uint8_t )USBD_FAIL ;
1600
+ }
1601
+
1552
1602
switch (SetMessage -> Oid )
1553
1603
{
1554
1604
case OID_GEN_CURRENT_PACKET_FILTER :
@@ -1600,6 +1650,11 @@ static uint8_t USBD_CDC_RNDIS_ProcessResetMsg(USBD_HandleTypeDef *pdev,
1600
1650
/* Use same Msg input buffer as response buffer */
1601
1651
USBD_CDC_RNDIS_ResetCpltMsgTypeDef * ResetResponse = (USBD_CDC_RNDIS_ResetCpltMsgTypeDef * )(void * )Msg ;
1602
1652
1653
+ if (hcdc == NULL )
1654
+ {
1655
+ return (uint8_t )USBD_FAIL ;
1656
+ }
1657
+
1603
1658
if ((ResetMessage -> MsgLength != sizeof (USBD_CDC_RNDIS_ResetMsgTypeDef )) || \
1604
1659
(ResetMessage -> Reserved != 0U ))
1605
1660
{
@@ -1647,6 +1702,11 @@ static uint8_t USBD_CDC_RNDIS_ProcessPacketMsg(USBD_HandleTypeDef *pdev,
1647
1702
/* Get and format the Msg input */
1648
1703
USBD_CDC_RNDIS_PacketMsgTypeDef * PacketMsg = (USBD_CDC_RNDIS_PacketMsgTypeDef * )Msg ;
1649
1704
1705
+ if (hcdc == NULL )
1706
+ {
1707
+ return (uint8_t )USBD_FAIL ;
1708
+ }
1709
+
1650
1710
/* Check correctness of the message */
1651
1711
if ((PacketMsg -> MsgType != CDC_RNDIS_PACKET_MSG_ID ))
1652
1712
{
@@ -1684,6 +1744,11 @@ static uint8_t USBD_CDC_RNDIS_ProcessUnsupportedMsg(USBD_HandleTypeDef *pdev,
1684
1744
/* Use same Msg input buffer as response buffer */
1685
1745
USBD_CDC_RNDIS_StsChangeMsgTypeDef * Response = (USBD_CDC_RNDIS_StsChangeMsgTypeDef * )(void * )Msg ;
1686
1746
1747
+ if (hcdc == NULL )
1748
+ {
1749
+ return (uint8_t )USBD_FAIL ;
1750
+ }
1751
+
1687
1752
/* Setup the response buffer content */
1688
1753
Response -> MsgType = CDC_RNDIS_INDICATE_STATUS_MSG_ID ;
1689
1754
Response -> MsgLength = sizeof (USBD_CDC_RNDIS_StsChangeMsgTypeDef );
0 commit comments