if (cam->control_buffer) kfree(cam->control_buffer); if (cam->data_buffer) kfree(cam->data_buffer); 
kfree(cam->control_buffer); kfree(cam->data_buffer); 
w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id){	struct usb_device *udev = interface_to_usbdev(intf);	struct w9968cf_device* cam;	int err = 0;	enum w9968cf_model_id mod_id;	struct list_head* ptr;	u8 sc = 0; /* number of simultaneous cameras */	static unsigned short dev_nr = 0; /* we are handling device number n */	if (le16_to_cpu(udev->descriptor.idVendor)  == winbond_id_table[0].idVendor &&	    le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[0].idProduct)		mod_id = W9968CF_MOD_CLVBWGP; /* see camlist[] table */	else if (le16_to_cpu(udev->descriptor.idVendor)  == winbond_id_table[1].idVendor &&	         le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[1].idProduct)		mod_id = W9968CF_MOD_GENERIC; /* see camlist[] table */	else		return -ENODEV;	cam = (struct w9968cf_device*)	          kmalloc(sizeof(struct w9968cf_device), GFP_KERNEL);	if (!cam)		return -ENOMEM;	memset(cam, 0, sizeof(*cam));	init_MUTEX(&cam->dev_sem);	down(&cam->dev_sem);	cam->usbdev = udev;	/* NOTE: a local copy is used to avoid possible race conditions */	memcpy(&cam->dev, &udev->dev, sizeof(struct device));	DBG(2, "%s detected", symbolic(camlist, mod_id))	if (simcams > W9968CF_MAX_DEVICES)		simcams = W9968CF_SIMCAMS;	/* How many cameras are connected ? */	down(&w9968cf_devlist_sem);	list_for_each(ptr, &w9968cf_dev_list)		sc++;	up(&w9968cf_devlist_sem);	if (sc >= simcams) {		DBG(2, "Device rejected: too many connected cameras "		       "(max. %u)", simcams)		err = -EPERM;		goto fail;	}	/* Allocate 2 bytes of memory for camera control USB transfers */	if (!(cam->control_buffer = (u16*)kmalloc(2, GFP_KERNEL))) {		DBG(1,"Couldn't allocate memory for camera control transfers")		err = -ENOMEM;		goto fail;	}	memset(cam->control_buffer, 0, 2);	/* Allocate 8 bytes of memory for USB data transfers to the FSB */	if (!(cam->data_buffer = (u16*)kmalloc(8, GFP_KERNEL))) {		DBG(1, "Couldn't allocate memory for data "		       "transfers to the FSB")		err = -ENOMEM;		goto fail;	}	memset(cam->data_buffer, 0, 8);	/* Register the V4L device */	cam->v4ldev = video_device_alloc();	if (!cam->v4ldev) {		DBG(1, "Could not allocate memory for a V4L structure")		err = -ENOMEM;		goto fail;	}	strcpy(cam->v4ldev->name, symbolic(camlist, mod_id));	cam->v4ldev->owner = THIS_MODULE;	cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES;	cam->v4ldev->hardware = VID_HARDWARE_W9968CF;	cam->v4ldev->fops = &w9968cf_fops;	cam->v4ldev->minor = video_nr[dev_nr];	cam->v4ldev->release = video_device_release;	video_set_drvdata(cam->v4ldev, cam);	cam->v4ldev->dev = &cam->dev;	err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,	                            video_nr[dev_nr]);	if (err) {		DBG(1, "V4L device registration failed")		if (err == -ENFILE && video_nr[dev_nr] == -1)			DBG(2, "Couldn't find a free /dev/videoX node")		video_nr[dev_nr] = -1;		dev_nr = (dev_nr < W9968CF_MAX_DEVICES-1) ? dev_nr+1 : 0;		goto fail;	}	DBG(2, "V4L device registered as /dev/video%d", cam->v4ldev->minor)	/* Set some basic constants */	w9968cf_configure_camera(cam, udev, mod_id, dev_nr);	/* Add a new entry into the list of V4L registered devices */	down(&w9968cf_devlist_sem);	list_add(&cam->v4llist, &w9968cf_dev_list);	up(&w9968cf_devlist_sem);	dev_nr = (dev_nr < W9968CF_MAX_DEVICES-1) ? dev_nr+1 : 0;	w9968cf_turn_on_led(cam);	w9968cf_i2c_init(cam);	usb_set_intfdata(intf, cam);	up(&cam->dev_sem);	return 0;fail: /* Free unused memory */	if (cam->control_buffer)		kfree(cam->control_buffer);	if (cam->data_buffer)		kfree(cam->data_buffer);	if (cam->v4ldev)		video_device_release(cam->v4ldev);	up(&cam->dev_sem);	kfree(cam);	return err;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/1bc3c9e1e44c2059fe2ffa6ff70ad0a925d7b05f/w9968cf.c/clean/drivers/usb/media/w9968cf.c