Skip to content

Commit 6171f7d

Browse files
jfischer-nojukkar
authored andcommitted
[nrf fromtree] 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]> (cherry picked from commit 1a5ab2c) Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit d7e1088)
1 parent 9238144 commit 6171f7d

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)