From: Alan Stern Date: Tue, 15 May 2007 21:40:37 +0000 (-0400) Subject: USB: don't try to kzalloc 0 bytes X-Git-Tag: v3.12-rc1~29363^2~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=57a21c1b929450b1e020c0a03cca6fa7448f4222;p=kernel%2Fkernel-generic.git USB: don't try to kzalloc 0 bytes This patch (as907) prevents us from trying to allocate 0 bytes when an interface has no endpoint descriptors. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index bfb3731..2d4fd53 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -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;