usb: device_next: fix null pointer dereference in Get Interface

Respond with a Request Error in default and addressed states.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit is contained in:
Johann Fischer 2024-11-26 12:58:00 +01:00 committed by Fabio Baltieri
commit 1a5ab2c16e

View file

@ -858,7 +858,13 @@ static int sreq_get_interface(struct usbd_context *const uds_ctx,
return 0;
}
/* Treat as error in default (not specified) and addressed states. */
cfg_nd = usbd_config_get_current(uds_ctx);
if (cfg_nd == NULL) {
errno = -EPERM;
return 0;
}
cfg_desc = cfg_nd->desc;
if (setup->wIndex > UINT8_MAX ||