On Fri, 16 Apr 2004, Oliver Neukum wrote: > Am Freitag, 16. April 2004 17:32 schrieb Alan Stern: > > + cp->interface[i] = intf = kmalloc(sizeof(*intf), > > GFP_KERNEL); + if (!intf) { > > + dev_err(&dev->dev, "Out of memory"); > > + while (--i >= 0) { > > + put_device(&cp->interface[i]->dev); > > + cp->interface[i] = NULL; > > + } > > + dev->actconfig = NULL; > > + return -ENOMEM; > > } > > Hi, > > is that sufficient cleanup? I don't feel well about having a > half initialised device hanging around. Maybe the loop should > be devided and the memory allocated in the first run.
I raised a similar point in the original version of this patch. If we run out of memory here, we end up with a configured device and dev->state is USB_STATE_CONFIGURED, but dev->actconfig is NULL and no interfaces are set up. In principle this shouldn't be a problem, but there might be code somewhere that assumes actconfig is valid if the state is CONFIGURED. Of course, there's another problem that's equally bad but less solvable. If the SET_CONFIGURATION message fails, the device is left in an unknown state, probably the same state as it was in before. But we have already disabled all the interfaces and unbound all the drivers. Presumably all the memory allocation should be done before clearing out the prior state, so that if we run out of memory nothing will have changed. How does that sound? Alan Stern ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel