USB: handle NULL config in usb_find_alt_setting()
authorAlan Stern <stern@rowland.harvard.edu>
Mon, 10 Sep 2018 18:00:53 +0000 (14:00 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 20 Sep 2018 10:49:12 +0000 (12:49 +0200)
commitc9a4cb204e9eb7fa7dfbe3f7d3a674fa530aa193
treec2dfa407774b6327f7bc364adc7fabc2935dd8a7
parentbd729f9d67aa9a303d8925bb8c4f06af25f407d1
USB: handle NULL config in usb_find_alt_setting()

usb_find_alt_setting() takes a pointer to a struct usb_host_config as
an argument; it searches for an interface with specified interface and
alternate setting numbers in that config.  However, it crashes if the
usb_host_config pointer argument is NULL.

Since this is a general-purpose routine, available for use in many
places, we want to to be more robust.  This patch makes it return NULL
whenever the config argument is NULL.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: syzbot+19c3aaef85a89d451eac@syzkaller.appspotmail.com
CC: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/usb.c