Skip to contentSkip to conversation

patch "USB: handle NULL config in usb_find_alt_setting()" added to usb-linus

PATCH [email protected] 1 participant 1 message Sep 20, 2018

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

USB: handle NULL config in usb_find_alt_setting()

to my usb git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
in the usb-linus branch.

The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)

The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.

If you have any questions about this process, please let me know.

Quoted 1 line

From c9a4cb204e9eb7fa7dfbe3f7d3a674fa530aa193 Mon Sep 17 00:00:00 2001

From: Alan Stern <[email protected]>
Date: Mon, 10 Sep 2018 14:00:53 -0400
Subject: 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.

---
 drivers/usb/core/usb.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/core/usb.c +2 -0
index 623be3174fb3..79d8bd7a612e 100644
@@ -228,6 +228,8 @@ struct usb_host_interface *usb_find_alt_setting(
 	struct usb_interface_cache *intf_cache = NULL;
 	int i;
 
+	if (!config)
+		return NULL;
 	for (i = 0; i < config->desc.bNumInterfaces; i++) {
 		if (config->intf_cache[i]->altsetting[0].desc.bInterfaceNumber
 				== iface_num) {
Signature · 1 line
2.19.0