Skip to content

Commit

Permalink
USB: don't try to kzalloc 0 bytes
Browse files Browse the repository at this point in the history
This patch (as907) prevents us from trying to allocate 0 bytes
when an interface has no endpoint descriptors.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed May 23, 2007
1 parent b89ee19 commit 57a21c1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/usb/core/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,12 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
num_ep = USB_MAXENDPOINTS;
}

len = sizeof(struct usb_host_endpoint) * num_ep;
alt->endpoint = kzalloc(len, GFP_KERNEL);
if (!alt->endpoint)
return -ENOMEM;
if (num_ep > 0) { /* Can't allocate 0 bytes */
len = sizeof(struct usb_host_endpoint) * num_ep;
alt->endpoint = kzalloc(len, GFP_KERNEL);
if (!alt->endpoint)
return -ENOMEM;
}

/* Parse all the endpoint descriptors */
n = 0;
Expand Down

0 comments on commit 57a21c1

Please sign in to comment.