Skip to content

Commit 1a5ab2c

Browse files
jfischer-nofabiobaltieri
authored andcommitted
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 <[email protected]>
1 parent 468ce19 commit 1a5ab2c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

subsys/usb/device_next/usbd_ch9.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,13 @@ static int sreq_get_interface(struct usbd_context *const uds_ctx,
858858
return 0;
859859
}
860860

861+
/* Treat as error in default (not specified) and addressed states. */
861862
cfg_nd = usbd_config_get_current(uds_ctx);
863+
if (cfg_nd == NULL) {
864+
errno = -EPERM;
865+
return 0;
866+
}
867+
862868
cfg_desc = cfg_nd->desc;
863869

864870
if (setup->wIndex > UINT8_MAX ||

0 commit comments

Comments
 (0)