@@ -186,6 +186,11 @@ static bool usbd_get_descriptor(uint8_t busid, uint16_t type_index, uint8_t **da
186
186
switch (type ) {
187
187
case USB_DESCRIPTOR_TYPE_DEVICE :
188
188
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
+ }
189
194
desc = g_usbd_core [busid ].descriptors -> device_descriptor_callback (g_usbd_core [busid ].speed );
190
195
if (desc == NULL ) {
191
196
found = false;
@@ -194,6 +199,10 @@ static bool usbd_get_descriptor(uint8_t busid, uint16_t type_index, uint8_t **da
194
199
desc_len = desc [0 ];
195
200
break ;
196
201
case USB_DESCRIPTOR_TYPE_CONFIGURATION :
202
+ if (g_usbd_core [busid ].descriptors -> config_descriptor_callback == NULL ) {
203
+ found = false;
204
+ break ;
205
+ }
197
206
desc = g_usbd_core [busid ].descriptors -> config_descriptor_callback (g_usbd_core [busid ].speed );
198
207
if (desc == NULL ) {
199
208
found = false;
@@ -214,6 +223,10 @@ static bool usbd_get_descriptor(uint8_t busid, uint16_t type_index, uint8_t **da
214
223
desc = (uint8_t * )g_usbd_core [busid ].descriptors -> msosv1_descriptor -> string ;
215
224
desc_len = g_usbd_core [busid ].descriptors -> msosv1_descriptor -> string [0 ];
216
225
} else {
226
+ if (g_usbd_core [busid ].descriptors -> string_descriptor_callback == NULL ) {
227
+ found = false;
228
+ break ;
229
+ }
217
230
string = g_usbd_core [busid ].descriptors -> string_descriptor_callback (g_usbd_core [busid ].speed , index );
218
231
if (string == NULL ) {
219
232
found = false;
@@ -253,6 +266,10 @@ static bool usbd_get_descriptor(uint8_t busid, uint16_t type_index, uint8_t **da
253
266
#ifndef CONFIG_USB_HS
254
267
return false;
255
268
#else
269
+ if (g_usbd_core [busid ].descriptors -> device_quality_descriptor_callback == NULL ) {
270
+ found = false;
271
+ break ;
272
+ }
256
273
desc = g_usbd_core [busid ].descriptors -> device_quality_descriptor_callback (g_usbd_core [busid ].speed );
257
274
if (desc == NULL ) {
258
275
found = false;
@@ -262,6 +279,10 @@ static bool usbd_get_descriptor(uint8_t busid, uint16_t type_index, uint8_t **da
262
279
break ;
263
280
#endif
264
281
case USB_DESCRIPTOR_TYPE_OTHER_SPEED :
282
+ if (g_usbd_core [busid ].descriptors -> other_speed_descriptor_callback == NULL ) {
283
+ found = false;
284
+ break ;
285
+ }
265
286
desc = g_usbd_core [busid ].descriptors -> other_speed_descriptor_callback (g_usbd_core [busid ].speed );
266
287
if (desc == NULL ) {
267
288
found = false;
0 commit comments