diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2018-09-10 14:00:53 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-09-20 06:49:12 -0400 |
commit | c9a4cb204e9eb7fa7dfbe3f7d3a674fa530aa193 (patch) | |
tree | c2dfa407774b6327f7bc364adc7fabc2935dd8a7 | |
parent | bd729f9d67aa9a303d8925bb8c4f06af25f407d1 (diff) |
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>
-rw-r--r-- | drivers/usb/core/usb.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 623be3174fb3..79d8bd7a612e 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -228,6 +228,8 @@ struct usb_host_interface *usb_find_alt_setting( | |||
228 | struct usb_interface_cache *intf_cache = NULL; | 228 | struct usb_interface_cache *intf_cache = NULL; |
229 | int i; | 229 | int i; |
230 | 230 | ||
231 | if (!config) | ||
232 | return NULL; | ||
231 | for (i = 0; i < config->desc.bNumInterfaces; i++) { | 233 | for (i = 0; i < config->desc.bNumInterfaces; i++) { |
232 | if (config->intf_cache[i]->altsetting[0].desc.bInterfaceNumber | 234 | if (config->intf_cache[i]->altsetting[0].desc.bInterfaceNumber |
233 | == iface_num) { | 235 | == iface_num) { |