Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Javier F. Arias <jarias.linux@gmail.com>
Link: https://lore.kernel.org/r/20191030030419.mmnrzm7hr4encfai@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Javier F. Arias and committed by
Greg Kroah-Hartman
67e7bd24 09ef6fde

+8 -10
+8 -10
drivers/staging/emxx_udc/emxx_udc.c
··· 2660 2660 2661 2661 /* make sure it's actually queued on this endpoint */ 2662 2662 list_for_each_entry(req, &ep->queue, queue) { 2663 - if (&req->req == _req) 2664 - break; 2663 + if (&req->req == _req) { 2664 + _nbu2ss_ep_done(ep, req, -ECONNRESET); 2665 + spin_unlock_irqrestore(&udc->lock, flags); 2666 + return 0; 2667 + } 2665 2668 } 2666 - if (&req->req != _req) { 2667 - spin_unlock_irqrestore(&udc->lock, flags); 2668 - pr_debug("%s no queue(EINVAL)\n", __func__); 2669 - return -EINVAL; 2670 - } 2671 - 2672 - _nbu2ss_ep_done(ep, req, -ECONNRESET); 2673 2669 2674 2670 spin_unlock_irqrestore(&udc->lock, flags); 2675 2671 2676 - return 0; 2672 + pr_debug("%s no queue(EINVAL)\n", __func__); 2673 + 2674 + return -EINVAL; 2677 2675 } 2678 2676 2679 2677 /*-------------------------------------------------------------------------*/