Skip to content

Commit

Permalink
usb: chipidea: udc: check request status before setting device address
Browse files Browse the repository at this point in the history
The complete() function may be called even though request is not
completed. In this case, it's necessary to check request status so
as not to set device address wrongly.

Fixes: 10775eb ("usb: chipidea: udc: update gadget states according to ch9")
cc: <stable@vger.kernel.org>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Link: https://lore.kernel.org/r/20220623030242.41796-1-xu.yang_2@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Xu Yang authored and Greg Kroah-Hartman committed Jun 24, 2022
1 parent 90bc2af commit b24346a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/usb/chipidea/udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,9 @@ isr_setup_status_complete(struct usb_ep *ep, struct usb_request *req)
struct ci_hdrc *ci = req->context;
unsigned long flags;

if (req->status < 0)
return;

if (ci->setaddr) {
hw_usb_set_address(ci, ci->address);
ci->setaddr = false;
Expand Down

0 comments on commit b24346a

Please sign in to comment.