Browse Source

USB: Avoid NULL pointer deref in usb_hcd_alloc_bandwidth.

usb_ifnum_to_if() can return NULL if the USB device does not have a
configuration installed (usb_device->actconfig == NULL), or if we can't
find the interface number in the installed configuration.  Return an
error instead of crashing.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Sarah Sharp 14 years ago
parent
commit
8a9af4fdf6
1 changed files with 2 additions and 0 deletions
  1. 2 0
      drivers/usb/core/hcd.c

+ 2 - 0
drivers/usb/core/hcd.c

@@ -1775,6 +1775,8 @@ int usb_hcd_alloc_bandwidth(struct usb_device *udev,
 		struct usb_interface *iface = usb_ifnum_to_if(udev,
 				cur_alt->desc.bInterfaceNumber);
 
+		if (!iface)
+			return -EINVAL;
 		if (iface->resetting_device) {
 			/*
 			 * The USB core just reset the device, so the xHCI host