if (uvd->sbuf[i].data != NULL) { kfree (uvd->sbuf[i].data); uvd->sbuf[i].data = NULL; } 
kfree(uvd->sbuf[i].data); uvd->sbuf[i].data = NULL; 
static int usbvideo_v4l_open(struct inode *inode, struct file *file){	struct video_device *dev = video_devdata(file);	struct uvd *uvd = (struct uvd *) dev;	const int sb_size = FRAMES_PER_DESC * uvd->iso_packet_len;	int i, errCode = 0;	if (uvd->debug > 1)		info("%s($%p)", __FUNCTION__, dev);	usbvideo_ClientIncModCount(uvd);	down(&uvd->lock);	if (uvd->user) {		err("%s: Someone tried to open an already opened device!", __FUNCTION__);		errCode = -EBUSY;	} else {		/* Clear statistics */		memset(&uvd->stats, 0, sizeof(uvd->stats));		/* Clean pointers so we know if we allocated something */		for (i=0; i < USBVIDEO_NUMSBUF; i++)			uvd->sbuf[i].data = NULL;		/* Allocate memory for the frame buffers */		uvd->fbuf_size = USBVIDEO_NUMFRAMES * uvd->max_frame_size;		uvd->fbuf = usbvideo_rvmalloc(uvd->fbuf_size);		RingQueue_Allocate(&uvd->dp, RING_QUEUE_SIZE);		if ((uvd->fbuf == NULL) ||		    (!RingQueue_IsAllocated(&uvd->dp))) {			err("%s: Failed to allocate fbuf or dp", __FUNCTION__);			errCode = -ENOMEM;		} else {			/* Allocate all buffers */			for (i=0; i < USBVIDEO_NUMFRAMES; i++) {				uvd->frame[i].frameState = FrameState_Unused;				uvd->frame[i].data = uvd->fbuf + i*(uvd->max_frame_size);				/*				 * Set default sizes in case IOCTL (VIDIOCMCAPTURE)				 * is not used (using read() instead).				 */				uvd->frame[i].canvas = uvd->canvas;				uvd->frame[i].seqRead_Index = 0;			}			for (i=0; i < USBVIDEO_NUMSBUF; i++) {				uvd->sbuf[i].data = kmalloc(sb_size, GFP_KERNEL);				if (uvd->sbuf[i].data == NULL) {					errCode = -ENOMEM;					break;				}			}		}		if (errCode != 0) {			/* Have to free all that memory */			if (uvd->fbuf != NULL) {				usbvideo_rvfree(uvd->fbuf, uvd->fbuf_size);				uvd->fbuf = NULL;			}			RingQueue_Free(&uvd->dp);			for (i=0; i < USBVIDEO_NUMSBUF; i++) {				if (uvd->sbuf[i].data != NULL) {					kfree (uvd->sbuf[i].data);					uvd->sbuf[i].data = NULL;				}			}		}	}	/* If so far no errors then we shall start the camera */	if (errCode == 0) {		/* Start data pump if we have valid endpoint */		if (uvd->video_endp != 0)			errCode = GET_CALLBACK(uvd, startDataPump)(uvd);		if (errCode == 0) {			if (VALID_CALLBACK(uvd, setupOnOpen)) {				if (uvd->debug > 1)					info("%s: setupOnOpen callback", __FUNCTION__);				errCode = GET_CALLBACK(uvd, setupOnOpen)(uvd);				if (errCode < 0) {					err("%s: setupOnOpen callback failed (%d.).",					    __FUNCTION__, errCode);				} else if (uvd->debug > 1) {					info("%s: setupOnOpen callback successful", __FUNCTION__);				}			}			if (errCode == 0) {				uvd->settingsAdjusted = 0;				if (uvd->debug > 1)					info("%s: Open succeeded.", __FUNCTION__);				uvd->user++;				file->private_data = uvd;			}		}	}	up(&uvd->lock);	if (errCode != 0)		usbvideo_ClientDecModCount(uvd);	if (uvd->debug > 0)		info("%s: Returning %d.", __FUNCTION__, errCode);	return errCode;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/1bc3c9e1e44c2059fe2ffa6ff70ad0a925d7b05f/usbvideo.c/buggy/drivers/usb/media/usbvideo.c