]> git.karo-electronics.de Git - linux-beck.git/commitdiff
USB: Avoid NULL pointer deref in usb_hcd_alloc_bandwidth.
authorSarah Sharp <sarah.a.sharp@linux.intel.com>
Tue, 9 Aug 2011 23:31:54 +0000 (16:31 -0700)
committerSarah Sharp <sarah.a.sharp@linux.intel.com>
Mon, 15 Aug 2011 16:22:40 +0000 (09:22 -0700)
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>
drivers/usb/core/hcd.c

index 8669ba3fe79486ffe487e6b6b266ff4767afe670..73cbbd85219fa5525b2968443d61a5c6f5086abd 100644 (file)
@@ -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