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

Commit cca3d0b7 authored by Pratham Pratap's avatar Pratham Pratap Committed by Gerrit - the friendly Code Review server
Browse files

usb: dwc3: Avoid NULL pointer access



dwc3_calc_trbs_left function is calling dwc3_ep_prev_trb
which can return NULL if trb pool is empty. This change adds
check for the return value of dwc3_ep_prev_trb function to
avoid NULL pointer dereference.

Change-Id: Id11d5ffd23da7c070d5e0b26842d8738b073b212
Signed-off-by: default avatarPratham Pratap <prathampratap@codeaurora.org>
parent f74ff626
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1088,7 +1088,7 @@ static u32 dwc3_calc_trbs_left(struct dwc3_ep *dep)
	 */
	if (dep->trb_enqueue == dep->trb_dequeue) {
		tmp = dwc3_ep_prev_trb(dep, dep->trb_enqueue);
		if (tmp->ctrl & DWC3_TRB_CTRL_HWO)
		if (!tmp || tmp->ctrl & DWC3_TRB_CTRL_HWO)
			return 0;

		return DWC3_TRB_NUM - 1;