Commit 05ddf410 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: more drivers/scsi annotations

	Almost all are trivial, aacraid/linit.c annotations had caught a bug -
copy_from_user() where copy_in_user() should've been.
parent 0056bf1e
...@@ -650,6 +650,7 @@ static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int ...@@ -650,6 +650,7 @@ static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
TW_Passthru *passthru; TW_Passthru *passthru;
TW_Device_Extension *tw_dev = tw_device_extension_list[iminor(inode)]; TW_Device_Extension *tw_dev = tw_device_extension_list[iminor(inode)];
int retval = -EFAULT; int retval = -EFAULT;
void __user *argp = (void __user *)arg;
dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl()\n"); dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl()\n");
...@@ -658,7 +659,7 @@ static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int ...@@ -658,7 +659,7 @@ static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
return -EINTR; return -EINTR;
/* First copy down the buffer length */ /* First copy down the buffer length */
error = copy_from_user(&data_buffer_length, (void *)arg, sizeof(unsigned int)); error = copy_from_user(&data_buffer_length, argp, sizeof(unsigned int));
if (error) if (error)
goto out; goto out;
...@@ -681,7 +682,7 @@ static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int ...@@ -681,7 +682,7 @@ static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
tw_ioctl = (TW_New_Ioctl *)cpu_addr; tw_ioctl = (TW_New_Ioctl *)cpu_addr;
/* Now copy down the entire ioctl */ /* Now copy down the entire ioctl */
error = copy_from_user(tw_ioctl, (void *)arg, data_buffer_length + sizeof(TW_New_Ioctl) - 1); error = copy_from_user(tw_ioctl, argp, data_buffer_length + sizeof(TW_New_Ioctl) - 1);
if (error) if (error)
goto out2; goto out2;
...@@ -788,7 +789,7 @@ static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int ...@@ -788,7 +789,7 @@ static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
} }
/* Now copy the response to userspace */ /* Now copy the response to userspace */
error = copy_to_user((void *)arg, tw_ioctl, sizeof(TW_New_Ioctl) + data_buffer_length - 1); error = copy_to_user(argp, tw_ioctl, sizeof(TW_New_Ioctl) + data_buffer_length - 1);
if (error == 0) if (error == 0)
retval = 0; retval = 0;
out2: out2:
......
...@@ -178,15 +178,14 @@ static struct aac_driver_ident aac_drivers[] = { ...@@ -178,15 +178,14 @@ static struct aac_driver_ident aac_drivers[] = {
static int aac_get_next_adapter_fib_ioctl(unsigned int fd, unsigned int cmd, static int aac_get_next_adapter_fib_ioctl(unsigned int fd, unsigned int cmd,
unsigned long arg, struct file *file) unsigned long arg, struct file *file)
{ {
struct fib_ioctl *f; struct fib_ioctl __user *f;
f = compat_alloc_user_space(sizeof(*f)); f = compat_alloc_user_space(sizeof(*f));
if (!access_ok(VERIFY_WRITE, f, sizeof(*f))) if (!access_ok(VERIFY_WRITE, f, sizeof(*f)))
return -EFAULT; return -EFAULT;
clear_user(f, sizeof(*f)); clear_user(f, sizeof(*f));
if (copy_from_user((void *)f, (void *)arg, if (copy_in_user(f, (void __user *)arg, sizeof(struct fib_ioctl) - sizeof(u32)))
sizeof(struct fib_ioctl) - sizeof(u32)))
return -EFAULT; return -EFAULT;
return sys_ioctl(fd, cmd, (unsigned long)f); return sys_ioctl(fd, cmd, (unsigned long)f);
......
...@@ -1635,14 +1635,14 @@ static int adpt_close(struct inode *inode, struct file *file) ...@@ -1635,14 +1635,14 @@ static int adpt_close(struct inode *inode, struct file *file)
} }
static int adpt_i2o_passthru(adpt_hba* pHba, u32* arg) static int adpt_i2o_passthru(adpt_hba* pHba, u32 __user *arg)
{ {
u32 msg[MAX_MESSAGE_SIZE]; u32 msg[MAX_MESSAGE_SIZE];
u32* reply = NULL; u32* reply = NULL;
u32 size = 0; u32 size = 0;
u32 reply_size = 0; u32 reply_size = 0;
u32* user_msg = (u32*)arg; u32 __user *user_msg = arg;
u32* user_reply = NULL; u32 __user * user_reply = NULL;
ulong sg_list[pHba->sg_tablesize]; ulong sg_list[pHba->sg_tablesize];
u32 sg_offset = 0; u32 sg_offset = 0;
u32 sg_count = 0; u32 sg_count = 0;
...@@ -1666,7 +1666,7 @@ static int adpt_i2o_passthru(adpt_hba* pHba, u32* arg) ...@@ -1666,7 +1666,7 @@ static int adpt_i2o_passthru(adpt_hba* pHba, u32* arg)
size *= 4; // Convert to bytes size *= 4; // Convert to bytes
/* Copy in the user's I2O command */ /* Copy in the user's I2O command */
if(copy_from_user((void*)msg, (void*)user_msg, size)) { if(copy_from_user(msg, user_msg, size)) {
return -EFAULT; return -EFAULT;
} }
get_user(reply_size, &user_reply[0]); get_user(reply_size, &user_reply[0]);
...@@ -1765,7 +1765,7 @@ static int adpt_i2o_passthru(adpt_hba* pHba, u32* arg) ...@@ -1765,7 +1765,7 @@ static int adpt_i2o_passthru(adpt_hba* pHba, u32* arg)
size = size>>16; size = size>>16;
size *= 4; size *= 4;
/* Copy in the user's I2O command */ /* Copy in the user's I2O command */
if (copy_from_user ((void*)msg, (void*)user_msg, size)) { if (copy_from_user (msg, user_msg, size)) {
rcode = -EFAULT; rcode = -EFAULT;
goto cleanup; goto cleanup;
} }
...@@ -1820,7 +1820,7 @@ static int adpt_i2o_passthru(adpt_hba* pHba, u32* arg) ...@@ -1820,7 +1820,7 @@ static int adpt_i2o_passthru(adpt_hba* pHba, u32* arg)
*/ */
/* Get all the info we can not get from kernel services */ /* Get all the info we can not get from kernel services */
static int adpt_system_info(void *buffer) static int adpt_system_info(void __user *buffer)
{ {
sysInfo_S si; sysInfo_S si;
...@@ -1916,6 +1916,7 @@ static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd, ...@@ -1916,6 +1916,7 @@ static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd,
int error = 0; int error = 0;
adpt_hba* pHba; adpt_hba* pHba;
ulong flags = 0; ulong flags = 0;
void __user *argp = (void __user *)arg;
minor = iminor(inode); minor = iminor(inode);
if (minor >= DPTI_MAX_HBA){ if (minor >= DPTI_MAX_HBA){
...@@ -1941,13 +1942,12 @@ static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd, ...@@ -1941,13 +1942,12 @@ static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd,
switch (cmd) { switch (cmd) {
// TODO: handle 3 cases // TODO: handle 3 cases
case DPT_SIGNATURE: case DPT_SIGNATURE:
if (copy_to_user((char*)arg, &DPTI_sig, sizeof(DPTI_sig))) { if (copy_to_user(argp, &DPTI_sig, sizeof(DPTI_sig))) {
return -EFAULT; return -EFAULT;
} }
break; break;
case I2OUSRCMD: case I2OUSRCMD:
return adpt_i2o_passthru(pHba,(u32*)arg); return adpt_i2o_passthru(pHba, argp);
break;
case DPT_CTRLINFO:{ case DPT_CTRLINFO:{
drvrHBAinfo_S HbaInfo; drvrHBAinfo_S HbaInfo;
...@@ -1963,19 +1963,18 @@ static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd, ...@@ -1963,19 +1963,18 @@ static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd,
HbaInfo.pciDeviceNum=PCI_SLOT(pHba->pDev->devfn); HbaInfo.pciDeviceNum=PCI_SLOT(pHba->pDev->devfn);
HbaInfo.Interrupt = pHba->pDev->irq; HbaInfo.Interrupt = pHba->pDev->irq;
HbaInfo.hbaFlags = FLG_OSD_PCI_VALID | FLG_OSD_DMA | FLG_OSD_I2O; HbaInfo.hbaFlags = FLG_OSD_PCI_VALID | FLG_OSD_DMA | FLG_OSD_I2O;
if(copy_to_user((void *) arg, &HbaInfo, sizeof(HbaInfo))){ if(copy_to_user(argp, &HbaInfo, sizeof(HbaInfo))){
printk(KERN_WARNING"%s: Could not copy HbaInfo TO user\n",pHba->name); printk(KERN_WARNING"%s: Could not copy HbaInfo TO user\n",pHba->name);
return -EFAULT; return -EFAULT;
} }
break; break;
} }
case DPT_SYSINFO: case DPT_SYSINFO:
return adpt_system_info((void*)arg); return adpt_system_info(argp);
break;
case DPT_BLINKLED:{ case DPT_BLINKLED:{
u32 value; u32 value;
value = (u32)adpt_read_blink_led(pHba); value = (u32)adpt_read_blink_led(pHba);
if (copy_to_user((char*)arg, &value, sizeof(value))) { if (copy_to_user(argp, &value, sizeof(value))) {
return -EFAULT; return -EFAULT;
} }
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment