Skip to content

Commit 973f914

Browse files
jfischer-nommahadevan108
authored andcommitted
drivers: udc_nrf: fix enqueue of control IN transfer with length 0
If the direction of the last setup packet is not to the device but to the host, then the transfer is not a status stage and should be queued. This is not checked and prevents a zero length control IN transfer to the host, e.g. used by the DFU class to indicate the end of the upload process. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
1 parent 0c299e6 commit 973f914

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/usb/udc/udc_nrf.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ static void udc_nrf_power_handler(nrfx_power_usb_evt_t pwr_evt)
487487
}
488488
}
489489

490-
static void udc_nrf_fake_status_in(const struct device *dev)
490+
static bool udc_nrf_fake_status_in(const struct device *dev)
491491
{
492492
struct udc_nrf_evt evt = {
493493
.type = UDC_NRF_EVT_STATUS_IN,
@@ -497,7 +497,10 @@ static void udc_nrf_fake_status_in(const struct device *dev)
497497
if (nrf_usbd_common_last_setup_dir_get() == USB_CONTROL_EP_OUT) {
498498
/* Let controller perform status IN stage */
499499
k_msgq_put(&drv_msgq, &evt, K_NO_WAIT);
500+
return true;
500501
}
502+
503+
return false;
501504
}
502505

503506
static int udc_nrf_ep_enqueue(const struct device *dev,
@@ -512,8 +515,9 @@ static int udc_nrf_ep_enqueue(const struct device *dev,
512515
udc_buf_put(cfg, buf);
513516

514517
if (cfg->addr == USB_CONTROL_EP_IN && buf->len == 0) {
515-
udc_nrf_fake_status_in(dev);
516-
return 0;
518+
if (udc_nrf_fake_status_in(dev)) {
519+
return 0;
520+
}
517521
}
518522

519523
k_msgq_put(&drv_msgq, &evt, K_NO_WAIT);

0 commit comments

Comments
 (0)