Skip to content
Permalink
Browse files

subsys: usb: stall if there is no data buffer

Return a STALL in the setup or data stage if there is no data buffer.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
  • Loading branch information...
jfischer-phytec-iot authored and galak committed May 7, 2018
1 parent 1b57752 commit 3a471e3240552e41e89887043c2e0c6a267353db
Showing with 8 additions and 0 deletions.
  1. +8 −0 subsys/usb/usb_device.c
@@ -271,6 +271,13 @@ static void usb_handle_control_transfer(u8_t ep,
/* Defaults for data pointer and residue */
type = REQTYPE_GET_TYPE(setup->bmRequestType);
usb_dev.data_buf = usb_dev.data_store[type];
if (!usb_dev.data_buf) {
SYS_LOG_DBG("buffer not available\n");
usb_dc_ep_set_stall(USB_CONTROL_OUT_EP0);
usb_dc_ep_set_stall(USB_CONTROL_IN_EP0);
return;
}

usb_dev.data_buf_residue = setup->wLength;
usb_dev.data_buf_len = setup->wLength;

@@ -310,6 +317,7 @@ static void usb_handle_control_transfer(u8_t ep,
usb_dev.data_buf_residue, &chunk) < 0) {
SYS_LOG_DBG("Read DATA Packet failed\n");
usb_dc_ep_set_stall(USB_CONTROL_IN_EP0);
usb_dc_ep_set_stall(USB_CONTROL_OUT_EP0);
return;
}

0 comments on commit 3a471e3

Please sign in to comment.
You can’t perform that action at this time.