]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
usb: gadget: core: Check for unset descriptor
authorChris Wulff <crwulff@gmail.com>
Thu, 25 Jul 2024 01:04:20 +0000 (21:04 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Aug 2024 13:34:27 +0000 (15:34 +0200)
commit716cba46f73a92645cf13eded8d257ed48afc2a4
treeae42b88ef69f7660b56436d678bc9178c6299c8d
parenteaf01a990645a0be78f9aeeae02bb7bd4794dfb0
usb: gadget: core: Check for unset descriptor

commit 973a57891608a98e894db2887f278777f564de18 upstream.

Make sure the descriptor has been set before looking at maxpacket.
This fixes a null pointer panic in this case.

This may happen if the gadget doesn't properly set up the endpoint
for the current speed, or the gadget descriptors are malformed and
the descriptor for the speed/endpoint are not found.

No current gadget driver is known to have this problem, but this
may cause a hard-to-find bug during development of new gadgets.

Fixes: 54f83b8c8ea9 ("USB: gadget: Reject endpoints with 0 maxpacket value")
Cc: stable@vger.kernel.org
Signed-off-by: Chris Wulff <crwulff@gmail.com>
Link: https://lore.kernel.org/r/20240725010419.314430-2-crwulff@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/udc/core.c