if (ov) { kfree(ov); ov = NULL; } 
kfree(ov); ov = NULL; 
ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id){	struct usb_device *dev = interface_to_usbdev(intf);	struct usb_interface_descriptor *idesc;	struct usb_ov511 *ov;	int i;	PDEBUG(1, "probing for device...");	/* We don't handle multi-config cameras */	if (dev->descriptor.bNumConfigurations != 1)		return -ENODEV;	idesc = &intf->cur_altsetting->desc;	if (idesc->bInterfaceClass != 0xFF)		return -ENODEV;	if (idesc->bInterfaceSubClass != 0x00)		return -ENODEV;	if ((ov = kmalloc(sizeof(*ov), GFP_KERNEL)) == NULL) {		err("couldn't kmalloc ov struct");		goto error_out;	}	memset(ov, 0, sizeof(*ov));	ov->dev = dev;	ov->iface = idesc->bInterfaceNumber;	ov->led_policy = led;	ov->compress = compress;	ov->lightfreq = lightfreq;	ov->num_inputs = 1;	   /* Video decoder init functs. change this */	ov->stop_during_set = !fastset;	ov->backlight = backlight;	ov->mirror = mirror;	ov->auto_brt = autobright;	ov->auto_gain = autogain;	ov->auto_exp = autoexp;	switch (le16_to_cpu(dev->descriptor.idProduct)) {	case PROD_OV511:		ov->bridge = BRG_OV511;		ov->bclass = BCL_OV511;		break;	case PROD_OV511PLUS:		ov->bridge = BRG_OV511PLUS;		ov->bclass = BCL_OV511;		break;	case PROD_OV518:		ov->bridge = BRG_OV518;		ov->bclass = BCL_OV518;		break;	case PROD_OV518PLUS:		ov->bridge = BRG_OV518PLUS;		ov->bclass = BCL_OV518;		break;	case PROD_ME2CAM:		if (le16_to_cpu(dev->descriptor.idVendor) != VEND_MATTEL)			goto error;		ov->bridge = BRG_OV511PLUS;		ov->bclass = BCL_OV511;		break;	default:		err("Unknown product ID 0x%04x", le16_to_cpu(dev->descriptor.idProduct));		goto error;	}	info("USB %s video device found", symbolic(brglist, ov->bridge));	init_waitqueue_head(&ov->wq);	init_MUTEX(&ov->lock);	/* to 1 == available */	init_MUTEX(&ov->buf_lock);	init_MUTEX(&ov->param_lock);	init_MUTEX(&ov->i2c_lock);	init_MUTEX(&ov->cbuf_lock);	ov->buf_state = BUF_NOT_ALLOCATED;	if (usb_make_path(dev, ov->usb_path, OV511_USB_PATH_LEN) < 0) {		err("usb_make_path error");		goto error;	}	/* Allocate control transfer buffer. */	/* Must be kmalloc()'ed, for DMA compatibility */	ov->cbuf = kmalloc(OV511_CBUF_SIZE, GFP_KERNEL);	if (!ov->cbuf)		goto error;	if (ov->bclass == BCL_OV518) {		if (ov518_configure(ov) < 0)			goto error;	} else {		if (ov511_configure(ov) < 0)			goto error;	}	for (i = 0; i < OV511_NUMFRAMES; i++) {		ov->frame[i].framenum = i;		init_waitqueue_head(&ov->frame[i].wq);	}	for (i = 0; i < OV511_NUMSBUF; i++) {		ov->sbuf[i].ov = ov;		spin_lock_init(&ov->sbuf[i].lock);		ov->sbuf[i].n = i;	}	/* Unnecessary? (This is done on open(). Need to make sure variables	 * are properly initialized without this before removing it, though). */	if (ov51x_set_default_params(ov) < 0)		goto error;#ifdef OV511_DEBUG	if (dump_bridge) {		if (ov->bclass == BCL_OV511)			ov511_dump_regs(ov);		else			ov518_dump_regs(ov);	}#endif	ov->vdev = video_device_alloc();	if (!ov->vdev)		goto error;	memcpy(ov->vdev, &vdev_template, sizeof(*ov->vdev));	ov->vdev->dev = &dev->dev;	video_set_drvdata(ov->vdev, ov);	for (i = 0; i < OV511_MAX_UNIT_VIDEO; i++) {		/* Minor 0 cannot be specified; assume user wants autodetect */		if (unit_video[i] == 0)			break;		if (video_register_device(ov->vdev, VFL_TYPE_GRABBER,			unit_video[i]) >= 0) {			break;		}	}	/* Use the next available one */	if ((ov->vdev->minor == -1) &&	    video_register_device(ov->vdev, VFL_TYPE_GRABBER, -1) < 0) {		err("video_register_device failed");		goto error;	}	info("Device at %s registered to minor %d", ov->usb_path,	     ov->vdev->minor);	usb_set_intfdata(intf, ov);	ov_create_sysfs(ov->vdev);	return 0;error:	if (ov->vdev) {		if (-1 == ov->vdev->minor)			video_device_release(ov->vdev);		else			video_unregister_device(ov->vdev);		ov->vdev = NULL;	}	if (ov->cbuf) {		down(&ov->cbuf_lock);		kfree(ov->cbuf);		ov->cbuf = NULL;		up(&ov->cbuf_lock);	}	if (ov) {		kfree(ov);		ov = NULL;	}error_out:	err("Camera initialization failed");	return -EIO;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/1bc3c9e1e44c2059fe2ffa6ff70ad0a925d7b05f/ov511.c/buggy/drivers/usb/media/ov511.c