if (copy_to_user(arg, (void *)kfib, le16_to_cpu(kfib->header.Size))) { fib_free(fibptr); return -EFAULT; 
retval = 0; if (copy_to_user(arg, (void *)kfib, size)) retval = -EFAULT; cleanup: if (hw_fib) { pci_free_consistent(dev->pdev, size, kfib, fibptr->hw_fib_pa); fibptr->hw_fib_pa = hw_fib_pa; fibptr->hw_fib = hw_fib; 
static int ioctl_send_fib(struct aac_dev * dev, void __user *arg){	struct hw_fib * kfib;	struct fib *fibptr;	fibptr = fib_alloc(dev);	if(fibptr == NULL)		return -ENOMEM;			kfib = fibptr->hw_fib;	/*	 *	First copy in the header so that we can check the size field.	 */	if (copy_from_user((void *)kfib, arg, sizeof(struct aac_fibhdr))) {		fib_free(fibptr);		return -EFAULT;	}	/*	 *	Since we copy based on the fib header size, make sure that we	 *	will not overrun the buffer when we copy the memory. Return	 *	an error if we would.	 */	if (le16_to_cpu(kfib->header.Size) > 			sizeof(struct hw_fib) - sizeof(struct aac_fibhdr)) {		fib_free(fibptr);		return -EINVAL;	}	if (copy_from_user(kfib, arg, le16_to_cpu(kfib->header.Size) +				sizeof(struct aac_fibhdr))) {		fib_free(fibptr);		return -EFAULT;	}	if (kfib->header.Command == cpu_to_le16(TakeABreakPt)) {		aac_adapter_interrupt(dev);		/*		 * Since we didn't really send a fib, zero out the state to allow 		 * cleanup code not to assert.		 */		kfib->header.XferState = 0;	} else {		int retval = fib_send(le16_to_cpu(kfib->header.Command), fibptr,				le16_to_cpu(kfib->header.Size) , FsaNormal,				1, 1, NULL, NULL);		if (retval) {			fib_free(fibptr);			return retval;		}		if (fib_complete(fibptr) != 0) {			fib_free(fibptr);			return -EINVAL;		}	}	/*	 *	Make sure that the size returned by the adapter (which includes	 *	the header) is less than or equal to the size of a fib, so we	 *	don't corrupt application data. Then copy that size to the user	 *	buffer. (Don't try to add the header information again, since it	 *	was already included by the adapter.)	 */	if (copy_to_user(arg, (void *)kfib, le16_to_cpu(kfib->header.Size))) {		fib_free(fibptr);		return -EFAULT;	}	fib_free(fibptr);	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/7c00ffa314bf0fb0e23858bbebad33b48b6abbb9/commctrl.c/clean/drivers/scsi/aacraid/commctrl.c