Skip to content

Commit

Permalink
[PATCH] USB: usbcore: usb_set_configuration oops (NULL ptr dereference)
Browse files Browse the repository at this point in the history
When trying to deconfigure a device via usb_set_configuration(dev, 0),
2.6.16-rc kernels after 55c5271 oops
with "Unable to handle NULL pointer dereference at...". This is due to
an unchecked dereference of cp in the power budget part.

Signed-off-by: Horst Schirmeier <horst@schirmeier.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Horst Schirmeier authored and Greg Kroah-Hartman committed Mar 20, 2006
1 parent 6aa3567 commit f48219d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions drivers/usb/core/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -1388,11 +1388,13 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
if (dev->state != USB_STATE_ADDRESS)
usb_disable_device (dev, 1); // Skip ep0

i = dev->bus_mA - cp->desc.bMaxPower * 2;
if (i < 0)
dev_warn(&dev->dev, "new config #%d exceeds power "
"limit by %dmA\n",
configuration, -i);
if (cp) {
i = dev->bus_mA - cp->desc.bMaxPower * 2;
if (i < 0)
dev_warn(&dev->dev, "new config #%d exceeds power "
"limit by %dmA\n",
configuration, -i);
}

if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
USB_REQ_SET_CONFIGURATION, 0, configuration, 0,
Expand Down

0 comments on commit f48219d

Please sign in to comment.