Skip to content

Commit b4cb808

Browse files
shuangpeng-kernelgregkh
authored andcommitted
USB: c67x00: fix use-after-free in c67x00_add_iso_urb()
commit b1e24de upstream. When TD creation fails for the last packet of an isochronous URB, c67x00_add_iso_urb() gives the URB back before updating the endpoint scheduling state. c67x00_giveback_urb() frees the URB private data, and the completion callback may release the final URB reference. The following accesses to urbp->ep_data, urb->interval, and urbp->cnt can therefore use freed memory. Update next_frame and cnt before giving back the failed final packet, making the giveback the last operation that uses the URB and its private data. Fixes: e9b29ff ("USB: add Cypress c67x00 OTG controller HCD driver") Cc: stable@vger.kernel.org Signed-off-by: Shuangpeng Bai <shuangpeng.kernel@gmail.com> Link: https://patch.msgid.link/20260806013502.322067-1-shuangpeng.kernel@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 683df50 commit b4cb808

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/usb/c67x00/c67x00-sched.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,13 +761,13 @@ static int c67x00_add_iso_urb(struct c67x00_hcd *c67x00, struct urb *urb)
761761
ret);
762762
urb->iso_frame_desc[urbp->cnt].actual_length = 0;
763763
urb->iso_frame_desc[urbp->cnt].status = ret;
764-
if (urbp->cnt + 1 == urb->number_of_packets)
765-
c67x00_giveback_urb(c67x00, urb, 0);
766764
}
767765

768766
urbp->ep_data->next_frame =
769767
frame_add(urbp->ep_data->next_frame, urb->interval);
770768
urbp->cnt++;
769+
if (ret && urbp->cnt == urb->number_of_packets)
770+
c67x00_giveback_urb(c67x00, urb, 0);
771771
}
772772
return 0;
773773
}

0 commit comments

Comments
 (0)