Skip to content

Commit

Permalink
[nrf fromtree] drivers: usb: udc_dwc2: Restrict TxFIFO to SPRAM size
Browse files Browse the repository at this point in the history
Do not allocate TxFIFO in a way that could corrupt Endpoint Information
Controller data (stored at DFIFO Depth address) or access locations
outside the SPRAM.

Signed-off-by: Tomasz Moń <[email protected]>
(cherry picked from commit 6582529)
Signed-off-by: Tomasz Moń <[email protected]>
  • Loading branch information
tmon-nordic committed Sep 23, 2024
1 parent d7881c1 commit ad923b1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/usb/udc/udc_dwc2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,11 @@ static int dwc2_set_dedicated_fifo(const struct device *dev,
return -ENOMEM;
}

/* Do not allocate TxFIFO outside the SPRAM */
if (txfaddr + txfdep > priv->dfifodepth) {
return -ENOMEM;
}

/* Set FIFO depth (32-bit words) and address */
dwc2_set_txf(dev, ep_idx - 1, txfdep, txfaddr);
} else {
Expand Down

0 comments on commit ad923b1

Please sign in to comment.