]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
usb: dwc3: gadget: Fix looping of queued SG entries
authorThinh Nguyen <Thinh.Nguyen@synopsys.com>
Thu, 14 Nov 2024 01:02:18 +0000 (01:02 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2024 18:51:18 +0000 (19:51 +0100)
commit0247da93bf62d33304b7bf97850ebf2a86e06d28
tree30259e2b15929c5a526985156a1fddb506f4e7ac
parent893f9ea3f6f11c6599f89b6048695d5639d31874
usb: dwc3: gadget: Fix looping of queued SG entries

commit b7fc65f5141c24785dc8c19249ca4efcf71b3524 upstream.

The dwc3_request->num_queued_sgs is decremented on completion. If a
partially completed request is handled, then the
dwc3_request->num_queued_sgs no longer reflects the total number of
num_queued_sgs (it would be cleared).

Correctly check the number of request SG entries remained to be prepare
and queued. Failure to do this may cause null pointer dereference when
accessing non-existent SG entry.

Cc: stable@vger.kernel.org
Fixes: c96e6725db9d ("usb: dwc3: gadget: Correct the logic for queuing sgs")
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://lore.kernel.org/r/d07a7c4aa0fcf746cdca0515150dbe5c52000af7.1731545781.git.Thinh.Nguyen@synopsys.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc3/gadget.c