Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 56b8b084 authored by Jack Pham's avatar Jack Pham
Browse files

usb: dwc3: gadget: Iterate only over valid endpoints



Make dwc3_gadget_resize_tx_fifos() iterate only over IN
endpoints that are actually present, based on the
num_in_eps parameter. This terminates the loop so as to
prevent dereferencing a potential NULL dwc->eps[i] where
i >= (num_in_eps + num_out_eps).

Change-Id: I07f711bfd380dce212e86b59cf417f84ca7eb006
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent 47d53bf2
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -198,15 +198,11 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc)
	 * FIFO space. Also consider the case where TxFIFO RAM space
	 * may change dynamically based on the USB configuration.
	 */
	for (num = 0; num < DWC3_ENDPOINTS_NUM; num++) {
		struct dwc3_ep	*dep = dwc->eps[num];
		int		fifo_number = dep->number >> 1;
	for (num = 0; num < dwc->num_in_eps; num++) {
		struct dwc3_ep	*dep = dwc->eps[(num << 1) | 1];
		int		mult = 1;
		int		tmp;

		if (!(dep->number & 1))
			continue;

		if (!(dep->flags & DWC3_EP_ENABLED))
			continue;

@@ -265,8 +261,7 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc)
			return -ENOMEM;
		}

		dwc3_writel(dwc->regs, DWC3_GTXFIFOSIZ(fifo_number),
				fifo_size);
		dwc3_writel(dwc->regs, DWC3_GTXFIFOSIZ(num), fifo_size);

	}