Commit 0b242dea authored by Tomasz Moń's avatar Tomasz Moń Committed by Carles Cufi
Browse files

drivers: udc_dwc2: Do not enable inactive endpoint



Fail TxFIFO write if the endpoint is not activated, because there is
essentially no fifo assigned. Writing to not activated endpoint is
possible, but it does tend to corrupt fifo number 0 which is used for
control transfers. USB stack should not really be attempting to write to
endpoints that have not been activated (ep_enable called).

Signed-off-by: default avatarTomasz Moń <tomasz.mon@nordicsemi.no>
parent c3daf6f2
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -409,6 +409,15 @@ static int dwc2_tx_fifo_write(const struct device *dev,
	}

	diepctl = sys_read32(diepctl_reg);
	if (!(diepctl & USB_DWC2_DEPCTL_USBACTEP)) {
		/* Do not attempt to write data on inactive endpoint, because
		 * no fifo is assigned to inactive endpoint and therefore it is
		 * possible that the write will corrupt other endpoint fifo.
		 */
		irq_unlock(key);
		return -ENOENT;
	}

	if (is_iso) {
		if (priv->sof_num & 1) {
			diepctl |= USB_DWC2_DEPCTL_SETODDFR;