提交 57a21c1b 编写于 作者: A Alan Stern 提交者: Greg Kroah-Hartman

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: NAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 b89ee19a
...@@ -185,10 +185,12 @@ static int usb_parse_interface(struct device *ddev, int cfgno, ...@@ -185,10 +185,12 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
num_ep = USB_MAXENDPOINTS; num_ep = USB_MAXENDPOINTS;
} }
len = sizeof(struct usb_host_endpoint) * num_ep; if (num_ep > 0) { /* Can't allocate 0 bytes */
alt->endpoint = kzalloc(len, GFP_KERNEL); len = sizeof(struct usb_host_endpoint) * num_ep;
if (!alt->endpoint) alt->endpoint = kzalloc(len, GFP_KERNEL);
return -ENOMEM; if (!alt->endpoint)
return -ENOMEM;
}
/* Parse all the endpoint descriptors */ /* Parse all the endpoint descriptors */
n = 0; n = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册