Greg:
This patch allocates a temporary array from the heap instead of from the
kernel's stack in usb_set_configuration(). It also updates a few
comments. Please apply.
Alan Stern
===== drivers/usb/core/message.c 1.82 vs edited =====
--- 1.82/drivers/usb/core/message.c Thu Apr 15 08:28:25 2004
+++ edited/drivers/usb/core/message.c Mon May 3 10:26:40 2004
@@ -1116,8 +1116,8 @@
{
int i, ret;
struct usb_host_config *cp = NULL;
- struct usb_interface *new_interfaces[USB_MAXINTERFACES];
- int n;
+ struct usb_interface **new_interfaces = NULL;
+ int n, nintf;
/* dev->serialize guards all config changes */
@@ -1139,9 +1139,17 @@
/* Allocate memory for new interfaces before doing anything else,
* so that if we run out then nothing will have changed. */
- n = 0;
+ n = nintf = 0;
if (cp) {
- for (; n < cp->desc.bNumInterfaces; ++n) {
+ nintf = cp->desc.bNumInterfaces;
+ new_interfaces = kmalloc(nintf * sizeof(*new_interfaces),
+ GFP_KERNEL);
+ if (!new_interfaces) {
+ dev_err(&dev->dev, "Out of memory");
+ return -ENOMEM;
+ }
+
+ for (; n < nintf; ++n) {
new_interfaces[n] = kmalloc(
sizeof(struct usb_interface),
GFP_KERNEL);
@@ -1151,6 +1159,7 @@
free_interfaces:
while (--n >= 0)
kfree(new_interfaces[n]);
+ kfree(new_interfaces);
return ret;
}
}
@@ -1173,11 +1182,10 @@
else {
dev->state = USB_STATE_CONFIGURED;
- /* re-initialize hc/hcd/usbcore interface/endpoint state.
- * this triggers binding of drivers to interfaces; and
- * maybe probe() calls will choose different altsettings.
+ /* Initialize the new interface structures and the
+ * hc/hcd/usbcore interface/endpoint state.
*/
- for (i = 0; i < cp->desc.bNumInterfaces; ++i) {
+ for (i = 0; i < nintf; ++i) {
struct usb_interface_cache *intfc;
struct usb_interface *intf;
struct usb_host_interface *alt;
@@ -1212,12 +1220,15 @@
configuration,
alt->desc.bInterfaceNumber);
}
+ kfree(new_interfaces);
- /* Now that all interfaces are setup, probe() calls
- * may claim() any interface that's not yet bound.
- * Many class drivers need that: CDC, audio, video, etc.
+ /* Now that all the interfaces are set up, register them
+ * to trigger binding of drivers to interfaces. probe()
+ * routines may install different altsettings and may
+ * claim() any interfaces not yet bound. Many class drivers
+ * need that: CDC, audio, video, etc.
*/
- for (i = 0; i < cp->desc.bNumInterfaces; ++i) {
+ for (i = 0; i < nintf; ++i) {
struct usb_interface *intf = cp->interface[i];
struct usb_interface_descriptor *desc;
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel