for (i = 0; i < MAX_AR_HEIGHT; i++) { if (ar->frame[i]) kfree(ar->frame[i]); } 
for (i = 0; i < MAX_AR_HEIGHT; i++) kfree(ar->frame[i]); 
static int __init ar_init(void){	struct ar_device *ar;	int ret;	int i;	DEBUG(1, "ar_init:\n");	ret = -EIO;	printk(KERN_INFO "arv: Colour AR VGA driver %s\n", VERSION);	ar = &ardev;	memset(ar, 0, sizeof(struct ar_device));#if USE_INT	/* allocate a DMA buffer for 1 line.  */	ar->line_buff = kmalloc(MAX_AR_LINE_BYTES, GFP_KERNEL | GFP_DMA);	if (ar->line_buff == NULL || ! ALIGN4(ar->line_buff)) {		printk("arv: buffer allocation failed for DMA.\n");		ret = -ENOMEM;		goto out_end;	}#endif	/* allocate buffers for a frame */	for (i = 0; i < MAX_AR_HEIGHT; i++) {		ar->frame[i] = kmalloc(MAX_AR_LINE_BYTES, GFP_KERNEL);		if (ar->frame[i] == NULL || ! ALIGN4(ar->frame[i])) {			printk("arv: buffer allocation failed for frame.\n");			ret = -ENOMEM;			goto out_line_buff;		}	}	ar->vdev = video_device_alloc();	if (!ar->vdev) {		printk(KERN_ERR "arv: video_device_alloc() failed\n");		return -ENOMEM;	}	memcpy(ar->vdev, &ar_template, sizeof(ar_template));	ar->vdev->priv = ar;	if (vga) {		ar->width 	= AR_WIDTH_VGA;		ar->height 	= AR_HEIGHT_VGA;		ar->size 	= AR_SIZE_VGA;		ar->frame_bytes = AR_FRAME_BYTES_VGA;		ar->line_bytes	= AR_LINE_BYTES_VGA;		if (vga_interlace)			ar->mode = AR_MODE_INTERLACE;		else			ar->mode = AR_MODE_NORMAL;	} else {		ar->width 	= AR_WIDTH_QVGA;		ar->height 	= AR_HEIGHT_QVGA;		ar->size 	= AR_SIZE_QVGA;		ar->frame_bytes = AR_FRAME_BYTES_QVGA;		ar->line_bytes	= AR_LINE_BYTES_QVGA;		ar->mode	= AR_MODE_INTERLACE;	}	init_MUTEX(&ar->lock);	init_waitqueue_head(&ar->wait);#if USE_INT	if (request_irq(M32R_IRQ_INT3, ar_interrupt, 0, "arv", ar)) {		printk("arv: request_irq(%d) failed.\n", M32R_IRQ_INT3);		ret = -EIO;		goto out_irq;	}#endif	if (ar_initialize(ar->vdev) != 0) {		printk("arv: M64278 not found.\n");		ret = -ENODEV;		goto out_dev;	}	/*	 * ok, we can initialize h/w according to parameters,	 * so register video device as a frame grabber type.	 * device is named "video[0-64]".	 * video_register_device() initializes h/w using ar_initialize(). 	 */	if (video_register_device(ar->vdev, VFL_TYPE_GRABBER, video_nr) != 0) {		/* return -1, -ENFILE(full) or others */		printk("arv: register video (Colour AR) failed.\n");		ret = -ENODEV;		goto out_dev;	}	printk("video%d: Found M64278 VGA (IRQ %d, Freq %dMHz).\n",		ar->vdev->minor, M32R_IRQ_INT3, freq);	return 0;out_dev:#if USE_INT	free_irq(M32R_IRQ_INT3, ar);out_irq:#endif	for (i = 0; i < MAX_AR_HEIGHT; i++) {		if (ar->frame[i])			kfree(ar->frame[i]);	}out_line_buff:#if USE_INT	kfree(ar->line_buff);out_end:#endif	return ret;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/2ea7533060e361810c21b2f5ee02151c4dfb85d8/arv.c/buggy/drivers/media/video/arv.c