Skip to content

Commit aedb0e0

Browse files
committed
USB: update STM32 USB Device library to v2.7.1
https://github.com/STMicroelectronics/stm32_mw_usb_device/releases/tag/v2.7.1 Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent bf499dd commit aedb0e0

File tree

12 files changed

+406
-26
lines changed

12 files changed

+406
-26
lines changed

system/Middlewares/ST/STM32_USB_Device_Library/Class/AUDIO/Src/usbd_audio.c

+25
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,11 @@ static uint8_t USBD_AUDIO_Setup(USBD_HandleTypeDef *pdev,
428428

429429
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassData;
430430

431+
if (haudio == NULL)
432+
{
433+
return (uint8_t)USBD_FAIL;
434+
}
435+
431436
switch (req->bmRequest & USB_REQ_TYPE_MASK)
432437
{
433438
case USB_REQ_TYPE_CLASS:
@@ -566,6 +571,11 @@ static uint8_t USBD_AUDIO_EP0_RxReady(USBD_HandleTypeDef *pdev)
566571
USBD_AUDIO_HandleTypeDef *haudio;
567572
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassData;
568573

574+
if (haudio == NULL)
575+
{
576+
return (uint8_t)USBD_FAIL;
577+
}
578+
569579
if (haudio->control.cmd == AUDIO_REQ_SET_CUR)
570580
{
571581
/* In this driver, to simplify code, only SET_CUR request is managed */
@@ -716,6 +726,11 @@ static uint8_t USBD_AUDIO_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
716726

717727
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassData;
718728

729+
if (haudio == NULL)
730+
{
731+
return (uint8_t)USBD_FAIL;
732+
}
733+
719734
if (epnum == AUDIO_OUT_EP)
720735
{
721736
/* Get received data packet length */
@@ -771,6 +786,11 @@ static void AUDIO_REQ_GetCurrent(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef
771786
USBD_AUDIO_HandleTypeDef *haudio;
772787
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassData;
773788

789+
if (haudio == NULL)
790+
{
791+
return;
792+
}
793+
774794
(void)USBD_memset(haudio->control.data, 0, 64U);
775795

776796
/* Send the current mute state */
@@ -789,6 +809,11 @@ static void AUDIO_REQ_SetCurrent(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef
789809
USBD_AUDIO_HandleTypeDef *haudio;
790810
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassData;
791811

812+
if (haudio == NULL)
813+
{
814+
return;
815+
}
816+
792817
if (req->wLength != 0U)
793818
{
794819
/* Prepare the reception of the buffer over EP0 */

system/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c

+20
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,11 @@ static uint8_t USBD_CDC_Setup(USBD_HandleTypeDef *pdev,
592592
uint16_t status_info = 0U;
593593
USBD_StatusTypeDef ret = USBD_OK;
594594

595+
if (hcdc == NULL)
596+
{
597+
return (uint8_t)USBD_FAIL;
598+
}
599+
595600
switch (req->bmRequest & USB_REQ_TYPE_MASK)
596601
{
597602
case USB_REQ_TYPE_CLASS:
@@ -753,6 +758,11 @@ static uint8_t USBD_CDC_EP0_RxReady(USBD_HandleTypeDef *pdev)
753758
{
754759
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassData;
755760

761+
if (hcdc == NULL)
762+
{
763+
return (uint8_t)USBD_FAIL;
764+
}
765+
756766
if ((pdev->pUserData != NULL) && (hcdc->CmdOpCode != 0xFFU))
757767
{
758768
((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Control(hcdc->CmdOpCode,
@@ -849,6 +859,11 @@ uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev,
849859
{
850860
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassData;
851861

862+
if (hcdc == NULL)
863+
{
864+
return (uint8_t)USBD_FAIL;
865+
}
866+
852867
hcdc->TxBuffer = pbuff;
853868
hcdc->TxLength = length;
854869

@@ -865,6 +880,11 @@ uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff)
865880
{
866881
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassData;
867882

883+
if (hcdc == NULL)
884+
{
885+
return (uint8_t)USBD_FAIL;
886+
}
887+
868888
hcdc->RxBuffer = pbuff;
869889

870890
return (uint8_t)USBD_OK;

system/Middlewares/ST/STM32_USB_Device_Library/Class/CDC_ECM/Src/usbd_cdc_ecm.c

+25
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,11 @@ static uint8_t USBD_CDC_ECM_Setup(USBD_HandleTypeDef *pdev,
619619
uint16_t status_info = 0U;
620620
uint8_t ifalt = 0U;
621621

622+
if (hcdc == NULL)
623+
{
624+
return (uint8_t)USBD_FAIL;
625+
}
626+
622627
switch (req->bmRequest & USB_REQ_TYPE_MASK)
623628
{
624629
case USB_REQ_TYPE_CLASS :
@@ -816,6 +821,11 @@ static uint8_t USBD_CDC_ECM_EP0_RxReady(USBD_HandleTypeDef *pdev)
816821
{
817822
USBD_CDC_ECM_HandleTypeDef *hcdc = (USBD_CDC_ECM_HandleTypeDef *)pdev->pClassData;
818823

824+
if (hcdc == NULL)
825+
{
826+
return (uint8_t)USBD_FAIL;
827+
}
828+
819829
if ((pdev->pUserData != NULL) && (hcdc->CmdOpCode != 0xFFU))
820830
{
821831
((USBD_CDC_ECM_ItfTypeDef *)pdev->pUserData)->Control(hcdc->CmdOpCode,
@@ -939,6 +949,11 @@ uint8_t USBD_CDC_ECM_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff, uint3
939949
{
940950
USBD_CDC_ECM_HandleTypeDef *hcdc = (USBD_CDC_ECM_HandleTypeDef *)pdev->pClassData;
941951

952+
if (hcdc == NULL)
953+
{
954+
return (uint8_t)USBD_FAIL;
955+
}
956+
942957
hcdc->TxBuffer = pbuff;
943958
hcdc->TxLength = length;
944959

@@ -956,6 +971,11 @@ uint8_t USBD_CDC_ECM_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff)
956971
{
957972
USBD_CDC_ECM_HandleTypeDef *hcdc = (USBD_CDC_ECM_HandleTypeDef *)pdev->pClassData;
958973

974+
if (hcdc == NULL)
975+
{
976+
return (uint8_t)USBD_FAIL;
977+
}
978+
959979
hcdc->RxBuffer = pbuff;
960980

961981
return (uint8_t)USBD_OK;
@@ -1034,6 +1054,11 @@ uint8_t USBD_CDC_ECM_SendNotification(USBD_HandleTypeDef *pdev,
10341054
USBD_CDC_ECM_HandleTypeDef *hcdc = (USBD_CDC_ECM_HandleTypeDef *)pdev->pClassData;
10351055
USBD_StatusTypeDef ret = USBD_OK;
10361056

1057+
if (hcdc == NULL)
1058+
{
1059+
return (uint8_t)USBD_FAIL;
1060+
}
1061+
10371062
/* Initialize the request fields */
10381063
(hcdc->Req).bmRequest = CDC_ECM_BMREQUEST_TYPE_ECM;
10391064
(hcdc->Req).bRequest = (uint8_t)Notif;

system/Middlewares/ST/STM32_USB_Device_Library/Class/CDC_RNDIS/Src/usbd_cdc_rndis.c

+65
Original file line numberDiff line numberDiff line change
@@ -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);

system/Middlewares/ST/STM32_USB_Device_Library/Class/CustomHID/Src/usbd_customhid.c

+10
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,11 @@ static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef *pdev,
448448
uint16_t status_info = 0U;
449449
USBD_StatusTypeDef ret = USBD_OK;
450450

451+
if (hhid == NULL)
452+
{
453+
return (uint8_t)USBD_FAIL;
454+
}
455+
451456
switch (req->bmRequest & USB_REQ_TYPE_MASK)
452457
{
453458
case USB_REQ_TYPE_CLASS:
@@ -713,6 +718,11 @@ static uint8_t USBD_CUSTOM_HID_EP0_RxReady(USBD_HandleTypeDef *pdev)
713718
{
714719
USBD_CUSTOM_HID_HandleTypeDef *hhid = (USBD_CUSTOM_HID_HandleTypeDef *)pdev->pClassData;
715720

721+
if (hhid == NULL)
722+
{
723+
return (uint8_t)USBD_FAIL;
724+
}
725+
716726
if (hhid->IsReportAvailable == 1U)
717727
{
718728
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData)->OutEvent(hhid->Report_buf[0],

0 commit comments

Comments
 (0)