usb: ehci: Use endpoint in URB to get maxpacket
authorKhalid Masum <khalid.masum.92@gmail.com>
Wed, 24 Aug 2022 19:38:13 +0000 (01:38 +0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 31 Aug 2022 07:07:53 +0000 (09:07 +0200)
commitd27c66adb4c0b16c817f71ba96e90f322e7419af
treeda43a6faca6ba7cb368fce24a7d88c714fa93708
parent4348f2e3ab3358898bfe93387ced7f3e1e3a6186
usb: ehci: Use endpoint in URB to get maxpacket

usb_maxpacket() looks up the endpoint number in the pipe which can fail
if the interface or configuration changes before the routine is called.
This is unexpected and may even cause a modulo by zero afterwards.

So use usb_endpoint_maxp() routine which uses the endpoint stored in URB
to get the maxpacket.

Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Khalid Masum <khalid.masum.92@gmail.com>
Addresses-Coverity: 744857 ("Division or modulo by zero")
Addresses-Coverity: 1487371 ("Division or modulo by zero")
Link: https://lore.kernel.org/r/20220824193813.13129-1-khalid.masum.92@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/ehci-q.c