if (buffer == NULL) { dev_err(&intf->dev, "Couldn't allocate string buffer\n"); goto error; } 
static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id *id){	struct usb_device *udev = interface_to_usbdev(intf);	struct ld_usb *dev = NULL;	struct usb_host_interface *iface_desc;	struct usb_endpoint_descriptor *endpoint;	char *buffer;	int i;	int retval = -ENOMEM;	/* allocate memory for our device state and intialize it */	dev = kmalloc(sizeof(*dev), GFP_KERNEL);	if (dev == NULL) {		dev_err(&intf->dev, "Out of memory\n");		goto exit;	}	memset(dev, 0x00, sizeof(*dev));	init_MUTEX(&dev->sem);	dev->intf = intf;	init_waitqueue_head(&dev->read_wait);	init_waitqueue_head(&dev->write_wait);	/* workaround for early firmware versions on fast computers */	if ((le16_to_cpu(udev->descriptor.idVendor) == USB_VENDOR_ID_LD) &&	    ((le16_to_cpu(udev->descriptor.idProduct) == USB_DEVICE_ID_CASSY) ||	     (le16_to_cpu(udev->descriptor.idProduct) == USB_DEVICE_ID_COM3LAB)) &&	    (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x103)) {		buffer = kmalloc(256, GFP_KERNEL);		/* usb_string makes SETUP+STALL to leave always ControlReadLoop */		usb_string(udev, 255, buffer, 256);		kfree(buffer);	}	iface_desc = intf->cur_altsetting;	/* set up the endpoint information */	for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {		endpoint = &iface_desc->endpoint[i].desc;		if (((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) &&		    ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {			dev->interrupt_in_endpoint = endpoint;		}		if (((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) &&		    ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {			dev->interrupt_out_endpoint = endpoint;		}	}	if (dev->interrupt_in_endpoint == NULL) {		dev_err(&intf->dev, "Interrupt in endpoint not found\n");		goto error;	}	if (dev->interrupt_out_endpoint == NULL)		dev_warn(&intf->dev, "Interrupt out endpoint not found (using control endpoint instead)\n");	dev->interrupt_in_endpoint_size = le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize);	dev->ring_buffer = kmalloc(ring_buffer_size*(sizeof(size_t)+dev->interrupt_in_endpoint_size), GFP_KERNEL);	if (!dev->ring_buffer) {		dev_err(&intf->dev, "Couldn't allocate ring_buffer\n");		goto error;	}	dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL);	if (!dev->interrupt_in_buffer) {		dev_err(&intf->dev, "Couldn't allocate interrupt_in_buffer\n");		goto error;	}	dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);	if (!dev->interrupt_in_urb) {		dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb\n");		goto error;	}	dev->interrupt_out_endpoint_size = dev->interrupt_out_endpoint ? le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize) :									 udev->descriptor.bMaxPacketSize0;	dev->interrupt_out_buffer = kmalloc(write_buffer_size*dev->interrupt_out_endpoint_size, GFP_KERNEL);	if (!dev->interrupt_out_buffer) {		dev_err(&intf->dev, "Couldn't allocate interrupt_out_buffer\n");		goto error;	}	dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);	if (!dev->interrupt_out_urb) {		dev_err(&intf->dev, "Couldn't allocate interrupt_out_urb\n");		goto error;	}	dev->interrupt_in_interval = min_interrupt_in_interval > dev->interrupt_in_endpoint->bInterval ? min_interrupt_in_interval : dev->interrupt_in_endpoint->bInterval;	if (dev->interrupt_out_endpoint)		dev->interrupt_out_interval = min_interrupt_out_interval > dev->interrupt_out_endpoint->bInterval ? min_interrupt_out_interval : dev->interrupt_out_endpoint->bInterval;	/* we can register the device now, as it is ready */	usb_set_intfdata(intf, dev);	retval = usb_register_dev(intf, &ld_usb_class);	if (retval) {		/* something prevented us from registering this driver */		dev_err(&intf->dev, "Not able to get a minor for this device.\n");		usb_set_intfdata(intf, NULL);		goto error;	}	/* let the user know what node this device is now attached to */	dev_info(&intf->dev, "LD USB Device #%d now attached to major %d minor %d\n",		(intf->minor - USB_LD_MINOR_BASE), USB_MAJOR, intf->minor);exit:	return retval;error:	ld_usb_delete(dev);	return retval;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/a6db592e1624bb7ec62cf56629c9556442169ac5/ldusb.c/clean/drivers/usb/misc/ldusb.c