@@ -186,6 +186,11 @@ static bool usbd_get_descriptor(uint8_t busid, uint16_t type_index, uint8_t **da
186186 switch (type ) {
187187 case USB_DESCRIPTOR_TYPE_DEVICE :
188188 g_usbd_core [busid ].speed = usbd_get_port_speed (busid ); /* before we get device descriptor, we have known steady port speed */
189+
190+ if (g_usbd_core [busid ].descriptors -> device_descriptor_callback == NULL ) {
191+ found = false;
192+ break ;
193+ }
189194 desc = g_usbd_core [busid ].descriptors -> device_descriptor_callback (g_usbd_core [busid ].speed );
190195 if (desc == NULL ) {
191196 found = false;
@@ -194,6 +199,10 @@ static bool usbd_get_descriptor(uint8_t busid, uint16_t type_index, uint8_t **da
194199 desc_len = desc [0 ];
195200 break ;
196201 case USB_DESCRIPTOR_TYPE_CONFIGURATION :
202+ if (g_usbd_core [busid ].descriptors -> config_descriptor_callback == NULL ) {
203+ found = false;
204+ break ;
205+ }
197206 desc = g_usbd_core [busid ].descriptors -> config_descriptor_callback (g_usbd_core [busid ].speed );
198207 if (desc == NULL ) {
199208 found = false;
@@ -214,6 +223,10 @@ static bool usbd_get_descriptor(uint8_t busid, uint16_t type_index, uint8_t **da
214223 desc = (uint8_t * )g_usbd_core [busid ].descriptors -> msosv1_descriptor -> string ;
215224 desc_len = g_usbd_core [busid ].descriptors -> msosv1_descriptor -> string [0 ];
216225 } else {
226+ if (g_usbd_core [busid ].descriptors -> string_descriptor_callback == NULL ) {
227+ found = false;
228+ break ;
229+ }
217230 string = g_usbd_core [busid ].descriptors -> string_descriptor_callback (g_usbd_core [busid ].speed , index );
218231 if (string == NULL ) {
219232 found = false;
@@ -253,6 +266,10 @@ static bool usbd_get_descriptor(uint8_t busid, uint16_t type_index, uint8_t **da
253266#ifndef CONFIG_USB_HS
254267 return false;
255268#else
269+ if (g_usbd_core [busid ].descriptors -> device_quality_descriptor_callback == NULL ) {
270+ found = false;
271+ break ;
272+ }
256273 desc = g_usbd_core [busid ].descriptors -> device_quality_descriptor_callback (g_usbd_core [busid ].speed );
257274 if (desc == NULL ) {
258275 found = false;
@@ -262,6 +279,10 @@ static bool usbd_get_descriptor(uint8_t busid, uint16_t type_index, uint8_t **da
262279 break ;
263280#endif
264281 case USB_DESCRIPTOR_TYPE_OTHER_SPEED :
282+ if (g_usbd_core [busid ].descriptors -> other_speed_descriptor_callback == NULL ) {
283+ found = false;
284+ break ;
285+ }
265286 desc = g_usbd_core [busid ].descriptors -> other_speed_descriptor_callback (g_usbd_core [busid ].speed );
266287 if (desc == NULL ) {
267288 found = false;
0 commit comments