Skip to contentSkip to conversation

staging: emxx_udc: Fix invalid reference error

PATCH New Javier F. Arias 1 participant 1 message Oct 30, 2019 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: emxx_udc: Fix invalid reference error

This patch fixes an invalid reference error by moving the code that is executed when a queue element is found, into the loop. Also, it removes an unnecessary test that now checks if the element is not present in the queue.
Issue found by Coccinelle.

---
 drivers/staging/emxx_udc/emxx_udc.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/staging/emxx_udc/emxx_udc.c +8 -10
index 9e0c19eb867c..667753c5e2ea 100644
@@ -2661,20 +2661,18 @@ static int nbu2ss_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 
 	/* make sure it's actually queued on this endpoint */
 	list_for_each_entry(req, &ep->queue, queue) {
-		if (&req->req == _req)
-			break;
-	}
-	if (&req->req != _req) {
-		spin_unlock_irqrestore(&udc->lock, flags);
-		pr_debug("%s no queue(EINVAL)\n", __func__);
-		return -EINVAL;
+		if (&req->req == _req) {
+			_nbu2ss_ep_done(ep, req, -ECONNRESET);
+			spin_unlock_irqrestore(&udc->lock, flags);
+			return 0;
+		}
 	}
 
-	_nbu2ss_ep_done(ep, req, -ECONNRESET);
-
 	spin_unlock_irqrestore(&udc->lock, flags);
 
-	return 0;
+	pr_debug("%s no queue(EINVAL)\n", __func__);
+
+	return -EINVAL;
 }
 
 /*-------------------------------------------------------------------------*/
Signature · 1 line
2.20.1