From patchwork Fri Feb 14 12:23:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Raghavendra X-Patchwork-Id: 236366 List-Id: U-Boot discussion From: vigneshr at ti.com (Vignesh Raghavendra) Date: Fri, 14 Feb 2020 17:53:28 +0530 Subject: [PATCH] usb: dwc3: Check that the request is valid in dwc3_gadget_giveback() Message-ID: <20200214122328.24987-1-vigneshr@ti.com> From: Jean-Jacques Hiblot This fixes potential issues reported by klokworks: Pointer 'req' returned from call to function 'next_request' at line 531 and 538 may be NULL and will be dereferenced in dwc3_gadget_giveback() Signed-off-by: Jean-Jacques Hiblot Signed-off-by: Vignesh Raghavendra --- drivers/usb/dwc3/gadget.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 4353dffb6b12..12de3b1da663 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -227,6 +227,9 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, { struct dwc3 *dwc = dep->dwc; + if (!req) + return; + if (req->queued) { dep->busy_slot++; /*