Commit dbba62f3 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: drivers/message/fusion annotations and fixes

Sigh...  First of all, LSI folks have very quaint idea of existing
platforms and word sizes on those.  Their definitions of U32 and S32
should really be reserved for posterity (preferably chiseled into the
rock they have between the ears), but kernel is the wrong place for
that.  Fixed.

mptctl_do_mpt_command() was always called on userland pointers;
kernel/userland argument removed along with dead code, function
annotated, callers updated.

The rest is trivial annotations in mptctl.c and in its ioctl structures
- nothing fancy there.
parent 17f5f84d
...@@ -47,18 +47,13 @@ typedef signed short S16; ...@@ -47,18 +47,13 @@ typedef signed short S16;
typedef unsigned short U16; typedef unsigned short U16;
#if defined(unix) || defined(__arm) || defined(ALPHA) typedef int32_t S32;
typedef u_int32_t U32;
typedef signed int S32;
typedef unsigned int U32;
#else
typedef signed long S32;
typedef unsigned long U32;
#endif
/*
* The only way crap below could work on big-endian boxen would be if it
* wasn't used at all.
*/
typedef struct _S64 typedef struct _S64
{ {
......
...@@ -144,8 +144,8 @@ static int mptctl_hp_targetinfo(unsigned long arg); ...@@ -144,8 +144,8 @@ static int mptctl_hp_targetinfo(unsigned long arg);
/* /*
* Private function calls. * Private function calls.
*/ */
static int mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local); static int mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr);
static int mptctl_do_fw_download(int ioc, char *ufwbuf, size_t fwlen); static int mptctl_do_fw_download(int ioc, char __user *ufwbuf, size_t fwlen);
static MptSge_t *kbuf_alloc_2_sgl( int bytes, u32 dir, int sge_offset, int *frags, static MptSge_t *kbuf_alloc_2_sgl( int bytes, u32 dir, int sge_offset, int *frags,
struct buflist **blp, dma_addr_t *sglbuf_dma, MPT_ADAPTER *ioc); struct buflist **blp, dma_addr_t *sglbuf_dma, MPT_ADAPTER *ioc);
static void kfree_sgl( MptSge_t *sgl, dma_addr_t sgl_dma, static void kfree_sgl( MptSge_t *sgl, dma_addr_t sgl_dma,
...@@ -563,7 +563,7 @@ mptctl_llseek(struct file *file, loff_t offset, int origin) ...@@ -563,7 +563,7 @@ mptctl_llseek(struct file *file, loff_t offset, int origin)
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
static ssize_t static ssize_t
mptctl_write(struct file *file, const char *buf, size_t count, loff_t *ppos) mptctl_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
{ {
printk(KERN_ERR MYNAM ": ioctl WRITE not yet supported\n"); printk(KERN_ERR MYNAM ": ioctl WRITE not yet supported\n");
return 0; return 0;
...@@ -571,7 +571,7 @@ mptctl_write(struct file *file, const char *buf, size_t count, loff_t *ppos) ...@@ -571,7 +571,7 @@ mptctl_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
static ssize_t static ssize_t
mptctl_read(struct file *file, char *buf, size_t count, loff_t *ptr) mptctl_read(struct file *file, char __user *buf, size_t count, loff_t *ptr)
{ {
printk(KERN_ERR MYNAM ": ioctl READ not yet supported\n"); printk(KERN_ERR MYNAM ": ioctl READ not yet supported\n");
return 0; return 0;
...@@ -586,7 +586,7 @@ mptctl_read(struct file *file, char *buf, size_t count, loff_t *ptr) ...@@ -586,7 +586,7 @@ mptctl_read(struct file *file, char *buf, size_t count, loff_t *ptr)
static int static int
mptctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) mptctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{ {
mpt_ioctl_header *uhdr = (mpt_ioctl_header *) arg; mpt_ioctl_header __user *uhdr = (void __user *) arg;
mpt_ioctl_header khdr; mpt_ioctl_header khdr;
int iocnum; int iocnum;
unsigned iocnumX; unsigned iocnumX;
...@@ -599,7 +599,7 @@ mptctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned ...@@ -599,7 +599,7 @@ mptctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned
if (copy_from_user(&khdr, uhdr, sizeof(khdr))) { if (copy_from_user(&khdr, uhdr, sizeof(khdr))) {
printk(KERN_ERR "%s::mptctl_ioctl() @%d - " printk(KERN_ERR "%s::mptctl_ioctl() @%d - "
"Unable to copy mpt_ioctl_header data @ %p\n", "Unable to copy mpt_ioctl_header data @ %p\n",
__FILE__, __LINE__, (void*)uhdr); __FILE__, __LINE__, uhdr);
return -EFAULT; return -EFAULT;
} }
ret = -ENXIO; /* (-6) No such device or address */ ret = -ENXIO; /* (-6) No such device or address */
...@@ -671,7 +671,7 @@ mptctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned ...@@ -671,7 +671,7 @@ mptctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned
static int mptctl_do_reset(unsigned long arg) static int mptctl_do_reset(unsigned long arg)
{ {
struct mpt_ioctl_diag_reset *urinfo = (struct mpt_ioctl_diag_reset *) arg; struct mpt_ioctl_diag_reset __user *urinfo = (void __user *) arg;
struct mpt_ioctl_diag_reset krinfo; struct mpt_ioctl_diag_reset krinfo;
MPT_ADAPTER *iocp; MPT_ADAPTER *iocp;
...@@ -680,7 +680,7 @@ static int mptctl_do_reset(unsigned long arg) ...@@ -680,7 +680,7 @@ static int mptctl_do_reset(unsigned long arg)
if (copy_from_user(&krinfo, urinfo, sizeof(struct mpt_ioctl_diag_reset))) { if (copy_from_user(&krinfo, urinfo, sizeof(struct mpt_ioctl_diag_reset))) {
printk(KERN_ERR "%s@%d::mptctl_do_reset - " printk(KERN_ERR "%s@%d::mptctl_do_reset - "
"Unable to copy mpt_ioctl_diag_reset struct @ %p\n", "Unable to copy mpt_ioctl_diag_reset struct @ %p\n",
__FILE__, __LINE__, (void*)urinfo); __FILE__, __LINE__, urinfo);
return -EFAULT; return -EFAULT;
} }
...@@ -734,14 +734,14 @@ static int mptctl_release(struct inode *inode, struct file *file) ...@@ -734,14 +734,14 @@ static int mptctl_release(struct inode *inode, struct file *file)
static int static int
mptctl_fw_download(unsigned long arg) mptctl_fw_download(unsigned long arg)
{ {
struct mpt_fw_xfer *ufwdl = (struct mpt_fw_xfer *) arg; struct mpt_fw_xfer __user *ufwdl = (void __user *) arg;
struct mpt_fw_xfer kfwdl; struct mpt_fw_xfer kfwdl;
dctlprintk((KERN_INFO "mptctl_fwdl called. mptctl_id = %xh\n", mptctl_id)); //tc dctlprintk((KERN_INFO "mptctl_fwdl called. mptctl_id = %xh\n", mptctl_id)); //tc
if (copy_from_user(&kfwdl, ufwdl, sizeof(struct mpt_fw_xfer))) { if (copy_from_user(&kfwdl, ufwdl, sizeof(struct mpt_fw_xfer))) {
printk(KERN_ERR "%s@%d::_ioctl_fwdl - " printk(KERN_ERR "%s@%d::_ioctl_fwdl - "
"Unable to copy mpt_fw_xfer struct @ %p\n", "Unable to copy mpt_fw_xfer struct @ %p\n",
__FILE__, __LINE__, (void*)ufwdl); __FILE__, __LINE__, ufwdl);
return -EFAULT; return -EFAULT;
} }
...@@ -763,7 +763,7 @@ mptctl_fw_download(unsigned long arg) ...@@ -763,7 +763,7 @@ mptctl_fw_download(unsigned long arg)
* -ENOMSG if FW upload returned bad status * -ENOMSG if FW upload returned bad status
*/ */
static int static int
mptctl_do_fw_download(int ioc, char *ufwbuf, size_t fwlen) mptctl_do_fw_download(int ioc, char __user *ufwbuf, size_t fwlen)
{ {
FWDownload_t *dlmsg; FWDownload_t *dlmsg;
MPT_FRAME_HDR *mf; MPT_FRAME_HDR *mf;
...@@ -892,7 +892,7 @@ mptctl_do_fw_download(int ioc, char *ufwbuf, size_t fwlen) ...@@ -892,7 +892,7 @@ mptctl_do_fw_download(int ioc, char *ufwbuf, size_t fwlen)
if (copy_from_user(bl->kptr, ufwbuf+fw_bytes_copied, bl->len)) { if (copy_from_user(bl->kptr, ufwbuf+fw_bytes_copied, bl->len)) {
printk(KERN_ERR "%s@%d::_ioctl_fwdl - " printk(KERN_ERR "%s@%d::_ioctl_fwdl - "
"Unable to copy f/w buffer hunk#%d @ %p\n", "Unable to copy f/w buffer hunk#%d @ %p\n",
__FILE__, __LINE__, n, (void*)ufwbuf); __FILE__, __LINE__, n, ufwbuf);
goto fwdl_out; goto fwdl_out;
} }
fw_bytes_copied += bl->len; fw_bytes_copied += bl->len;
...@@ -1198,7 +1198,7 @@ kfree_sgl(MptSge_t *sgl, dma_addr_t sgl_dma, struct buflist *buflist, MPT_ADAPTE ...@@ -1198,7 +1198,7 @@ kfree_sgl(MptSge_t *sgl, dma_addr_t sgl_dma, struct buflist *buflist, MPT_ADAPTE
static int static int
mptctl_getiocinfo (unsigned long arg, unsigned int data_size) mptctl_getiocinfo (unsigned long arg, unsigned int data_size)
{ {
struct mpt_ioctl_iocinfo *uarg = (struct mpt_ioctl_iocinfo *) arg; struct mpt_ioctl_iocinfo __user *uarg = (void __user *) arg;
struct mpt_ioctl_iocinfo *karg; struct mpt_ioctl_iocinfo *karg;
MPT_ADAPTER *ioc; MPT_ADAPTER *ioc;
struct pci_dev *pdev; struct pci_dev *pdev;
...@@ -1238,7 +1238,7 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size) ...@@ -1238,7 +1238,7 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size)
if (copy_from_user(karg, uarg, data_size)) { if (copy_from_user(karg, uarg, data_size)) {
printk(KERN_ERR "%s@%d::mptctl_getiocinfo - " printk(KERN_ERR "%s@%d::mptctl_getiocinfo - "
"Unable to read in mpt_ioctl_iocinfo struct @ %p\n", "Unable to read in mpt_ioctl_iocinfo struct @ %p\n",
__FILE__, __LINE__, (void*)uarg); __FILE__, __LINE__, uarg);
kfree(karg); kfree(karg);
return -EFAULT; return -EFAULT;
} }
...@@ -1335,10 +1335,10 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size) ...@@ -1335,10 +1335,10 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size)
/* Copy the data from kernel memory to user memory /* Copy the data from kernel memory to user memory
*/ */
if (copy_to_user((char *)arg, karg, data_size)) { if (copy_to_user((char __user *)arg, karg, data_size)) {
printk(KERN_ERR "%s@%d::mptctl_getiocinfo - " printk(KERN_ERR "%s@%d::mptctl_getiocinfo - "
"Unable to write out mpt_ioctl_iocinfo struct @ %p\n", "Unable to write out mpt_ioctl_iocinfo struct @ %p\n",
__FILE__, __LINE__, (void*)uarg); __FILE__, __LINE__, uarg);
kfree(karg); kfree(karg);
return -EFAULT; return -EFAULT;
} }
...@@ -1360,7 +1360,7 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size) ...@@ -1360,7 +1360,7 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size)
static int static int
mptctl_gettargetinfo (unsigned long arg) mptctl_gettargetinfo (unsigned long arg)
{ {
struct mpt_ioctl_targetinfo *uarg = (struct mpt_ioctl_targetinfo *) arg; struct mpt_ioctl_targetinfo __user *uarg = (void __user *) arg;
struct mpt_ioctl_targetinfo karg; struct mpt_ioctl_targetinfo karg;
MPT_ADAPTER *ioc; MPT_ADAPTER *ioc;
struct Scsi_Host *sh; struct Scsi_Host *sh;
...@@ -1382,7 +1382,7 @@ mptctl_gettargetinfo (unsigned long arg) ...@@ -1382,7 +1382,7 @@ mptctl_gettargetinfo (unsigned long arg)
if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_targetinfo))) { if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_targetinfo))) {
printk(KERN_ERR "%s@%d::mptctl_gettargetinfo - " printk(KERN_ERR "%s@%d::mptctl_gettargetinfo - "
"Unable to read in mpt_ioctl_targetinfo struct @ %p\n", "Unable to read in mpt_ioctl_targetinfo struct @ %p\n",
__FILE__, __LINE__, (void*)uarg); __FILE__, __LINE__, uarg);
return -EFAULT; return -EFAULT;
} }
...@@ -1500,21 +1500,21 @@ mptctl_gettargetinfo (unsigned long arg) ...@@ -1500,21 +1500,21 @@ mptctl_gettargetinfo (unsigned long arg)
/* Copy part of the data from kernel memory to user memory /* Copy part of the data from kernel memory to user memory
*/ */
if (copy_to_user((char *)arg, &karg, if (copy_to_user((char __user *)arg, &karg,
sizeof(struct mpt_ioctl_targetinfo))) { sizeof(struct mpt_ioctl_targetinfo))) {
printk(KERN_ERR "%s@%d::mptctl_gettargetinfo - " printk(KERN_ERR "%s@%d::mptctl_gettargetinfo - "
"Unable to write out mpt_ioctl_targetinfo struct @ %p\n", "Unable to write out mpt_ioctl_targetinfo struct @ %p\n",
__FILE__, __LINE__, (void*)uarg); __FILE__, __LINE__, uarg);
kfree(pmem); kfree(pmem);
return -EFAULT; return -EFAULT;
} }
/* Copy the remaining data from kernel memory to user memory /* Copy the remaining data from kernel memory to user memory
*/ */
if (copy_to_user((char *) uarg->targetInfo, pmem, numBytes)) { if (copy_to_user(uarg->targetInfo, pmem, numBytes)) {
printk(KERN_ERR "%s@%d::mptctl_gettargetinfo - " printk(KERN_ERR "%s@%d::mptctl_gettargetinfo - "
"Unable to write out mpt_ioctl_targetinfo struct @ %p\n", "Unable to write out mpt_ioctl_targetinfo struct @ %p\n",
__FILE__, __LINE__, (void*)pdata); __FILE__, __LINE__, pdata);
kfree(pmem); kfree(pmem);
return -EFAULT; return -EFAULT;
} }
...@@ -1535,7 +1535,7 @@ mptctl_gettargetinfo (unsigned long arg) ...@@ -1535,7 +1535,7 @@ mptctl_gettargetinfo (unsigned long arg)
static int static int
mptctl_readtest (unsigned long arg) mptctl_readtest (unsigned long arg)
{ {
struct mpt_ioctl_test *uarg = (struct mpt_ioctl_test *) arg; struct mpt_ioctl_test __user *uarg = (void __user *) arg;
struct mpt_ioctl_test karg; struct mpt_ioctl_test karg;
MPT_ADAPTER *ioc; MPT_ADAPTER *ioc;
int iocnum; int iocnum;
...@@ -1544,7 +1544,7 @@ mptctl_readtest (unsigned long arg) ...@@ -1544,7 +1544,7 @@ mptctl_readtest (unsigned long arg)
if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_test))) { if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_test))) {
printk(KERN_ERR "%s@%d::mptctl_readtest - " printk(KERN_ERR "%s@%d::mptctl_readtest - "
"Unable to read in mpt_ioctl_test struct @ %p\n", "Unable to read in mpt_ioctl_test struct @ %p\n",
__FILE__, __LINE__, (void*)uarg); __FILE__, __LINE__, uarg);
return -EFAULT; return -EFAULT;
} }
...@@ -1571,10 +1571,10 @@ mptctl_readtest (unsigned long arg) ...@@ -1571,10 +1571,10 @@ mptctl_readtest (unsigned long arg)
/* Copy the data from kernel memory to user memory /* Copy the data from kernel memory to user memory
*/ */
if (copy_to_user((char *)arg, &karg, sizeof(struct mpt_ioctl_test))) { if (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_test))) {
printk(KERN_ERR "%s@%d::mptctl_readtest - " printk(KERN_ERR "%s@%d::mptctl_readtest - "
"Unable to write out mpt_ioctl_test struct @ %p\n", "Unable to write out mpt_ioctl_test struct @ %p\n",
__FILE__, __LINE__, (void*)uarg); __FILE__, __LINE__, uarg);
return -EFAULT; return -EFAULT;
} }
...@@ -1595,7 +1595,7 @@ mptctl_readtest (unsigned long arg) ...@@ -1595,7 +1595,7 @@ mptctl_readtest (unsigned long arg)
static int static int
mptctl_eventquery (unsigned long arg) mptctl_eventquery (unsigned long arg)
{ {
struct mpt_ioctl_eventquery *uarg = (struct mpt_ioctl_eventquery *) arg; struct mpt_ioctl_eventquery __user *uarg = (void __user *) arg;
struct mpt_ioctl_eventquery karg; struct mpt_ioctl_eventquery karg;
MPT_ADAPTER *ioc; MPT_ADAPTER *ioc;
int iocnum; int iocnum;
...@@ -1604,7 +1604,7 @@ mptctl_eventquery (unsigned long arg) ...@@ -1604,7 +1604,7 @@ mptctl_eventquery (unsigned long arg)
if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventquery))) { if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventquery))) {
printk(KERN_ERR "%s@%d::mptctl_eventquery - " printk(KERN_ERR "%s@%d::mptctl_eventquery - "
"Unable to read in mpt_ioctl_eventquery struct @ %p\n", "Unable to read in mpt_ioctl_eventquery struct @ %p\n",
__FILE__, __LINE__, (void*)uarg); __FILE__, __LINE__, uarg);
return -EFAULT; return -EFAULT;
} }
...@@ -1620,10 +1620,10 @@ mptctl_eventquery (unsigned long arg) ...@@ -1620,10 +1620,10 @@ mptctl_eventquery (unsigned long arg)
/* Copy the data from kernel memory to user memory /* Copy the data from kernel memory to user memory
*/ */
if (copy_to_user((char *)arg, &karg, sizeof(struct mpt_ioctl_eventquery))) { if (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_eventquery))) {
printk(KERN_ERR "%s@%d::mptctl_eventquery - " printk(KERN_ERR "%s@%d::mptctl_eventquery - "
"Unable to write out mpt_ioctl_eventquery struct @ %p\n", "Unable to write out mpt_ioctl_eventquery struct @ %p\n",
__FILE__, __LINE__, (void*)uarg); __FILE__, __LINE__, uarg);
return -EFAULT; return -EFAULT;
} }
return 0; return 0;
...@@ -1633,7 +1633,7 @@ mptctl_eventquery (unsigned long arg) ...@@ -1633,7 +1633,7 @@ mptctl_eventquery (unsigned long arg)
static int static int
mptctl_eventenable (unsigned long arg) mptctl_eventenable (unsigned long arg)
{ {
struct mpt_ioctl_eventenable *uarg = (struct mpt_ioctl_eventenable *) arg; struct mpt_ioctl_eventenable __user *uarg = (void __user *) arg;
struct mpt_ioctl_eventenable karg; struct mpt_ioctl_eventenable karg;
MPT_ADAPTER *ioc; MPT_ADAPTER *ioc;
int iocnum; int iocnum;
...@@ -1642,7 +1642,7 @@ mptctl_eventenable (unsigned long arg) ...@@ -1642,7 +1642,7 @@ mptctl_eventenable (unsigned long arg)
if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventenable))) { if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventenable))) {
printk(KERN_ERR "%s@%d::mptctl_eventenable - " printk(KERN_ERR "%s@%d::mptctl_eventenable - "
"Unable to read in mpt_ioctl_eventenable struct @ %p\n", "Unable to read in mpt_ioctl_eventenable struct @ %p\n",
__FILE__, __LINE__, (void*)uarg); __FILE__, __LINE__, uarg);
return -EFAULT; return -EFAULT;
} }
...@@ -1680,7 +1680,7 @@ mptctl_eventenable (unsigned long arg) ...@@ -1680,7 +1680,7 @@ mptctl_eventenable (unsigned long arg)
static int static int
mptctl_eventreport (unsigned long arg) mptctl_eventreport (unsigned long arg)
{ {
struct mpt_ioctl_eventreport *uarg = (struct mpt_ioctl_eventreport *) arg; struct mpt_ioctl_eventreport __user *uarg = (void __user *) arg;
struct mpt_ioctl_eventreport karg; struct mpt_ioctl_eventreport karg;
MPT_ADAPTER *ioc; MPT_ADAPTER *ioc;
int iocnum; int iocnum;
...@@ -1690,7 +1690,7 @@ mptctl_eventreport (unsigned long arg) ...@@ -1690,7 +1690,7 @@ mptctl_eventreport (unsigned long arg)
if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventreport))) { if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventreport))) {
printk(KERN_ERR "%s@%d::mptctl_eventreport - " printk(KERN_ERR "%s@%d::mptctl_eventreport - "
"Unable to read in mpt_ioctl_eventreport struct @ %p\n", "Unable to read in mpt_ioctl_eventreport struct @ %p\n",
__FILE__, __LINE__, (void*)uarg); __FILE__, __LINE__, uarg);
return -EFAULT; return -EFAULT;
} }
...@@ -1716,10 +1716,10 @@ mptctl_eventreport (unsigned long arg) ...@@ -1716,10 +1716,10 @@ mptctl_eventreport (unsigned long arg)
/* Copy the data from kernel memory to user memory /* Copy the data from kernel memory to user memory
*/ */
numBytes = max * sizeof(MPT_IOCTL_EVENTS); numBytes = max * sizeof(MPT_IOCTL_EVENTS);
if (copy_to_user((char *) uarg->eventData, ioc->events, numBytes)) { if (copy_to_user(uarg->eventData, ioc->events, numBytes)) {
printk(KERN_ERR "%s@%d::mptctl_eventreport - " printk(KERN_ERR "%s@%d::mptctl_eventreport - "
"Unable to write out mpt_ioctl_eventreport struct @ %p\n", "Unable to write out mpt_ioctl_eventreport struct @ %p\n",
__FILE__, __LINE__, (void*)ioc->events); __FILE__, __LINE__, ioc->events);
return -EFAULT; return -EFAULT;
} }
...@@ -1730,7 +1730,7 @@ mptctl_eventreport (unsigned long arg) ...@@ -1730,7 +1730,7 @@ mptctl_eventreport (unsigned long arg)
static int static int
mptctl_replace_fw (unsigned long arg) mptctl_replace_fw (unsigned long arg)
{ {
struct mpt_ioctl_replace_fw *uarg = (struct mpt_ioctl_replace_fw *) arg; struct mpt_ioctl_replace_fw __user *uarg = (void __user *) arg;
struct mpt_ioctl_replace_fw karg; struct mpt_ioctl_replace_fw karg;
MPT_ADAPTER *ioc; MPT_ADAPTER *ioc;
fw_image_t **fwmem = NULL; fw_image_t **fwmem = NULL;
...@@ -1744,7 +1744,7 @@ mptctl_replace_fw (unsigned long arg) ...@@ -1744,7 +1744,7 @@ mptctl_replace_fw (unsigned long arg)
if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_replace_fw))) { if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_replace_fw))) {
printk(KERN_ERR "%s@%d::mptctl_replace_fw - " printk(KERN_ERR "%s@%d::mptctl_replace_fw - "
"Unable to read in mpt_ioctl_replace_fw struct @ %p\n", "Unable to read in mpt_ioctl_replace_fw struct @ %p\n",
__FILE__, __LINE__, (void*)uarg); __FILE__, __LINE__, uarg);
return -EFAULT; return -EFAULT;
} }
...@@ -1774,7 +1774,7 @@ mptctl_replace_fw (unsigned long arg) ...@@ -1774,7 +1774,7 @@ mptctl_replace_fw (unsigned long arg)
if (copy_from_user(fwmem[ii]->fw, uarg->newImage + offset, fwmem[ii]->size)) { if (copy_from_user(fwmem[ii]->fw, uarg->newImage + offset, fwmem[ii]->size)) {
printk(KERN_ERR "%s@%d::mptctl_replace_fw - " printk(KERN_ERR "%s@%d::mptctl_replace_fw - "
"Unable to read in mpt_ioctl_replace_fw image @ %p\n", "Unable to read in mpt_ioctl_replace_fw image @ %p\n",
__FILE__, __LINE__, (void*)uarg); __FILE__, __LINE__, uarg);
mpt_free_fw_memory(ioc, fwmem); mpt_free_fw_memory(ioc, fwmem);
return -EFAULT; return -EFAULT;
...@@ -1819,7 +1819,7 @@ mptctl_replace_fw (unsigned long arg) ...@@ -1819,7 +1819,7 @@ mptctl_replace_fw (unsigned long arg)
static int static int
mptctl_mpt_command (unsigned long arg) mptctl_mpt_command (unsigned long arg)
{ {
struct mpt_ioctl_command *uarg = (struct mpt_ioctl_command *) arg; struct mpt_ioctl_command __user *uarg = (void __user *) arg;
struct mpt_ioctl_command karg; struct mpt_ioctl_command karg;
MPT_ADAPTER *ioc; MPT_ADAPTER *ioc;
int iocnum; int iocnum;
...@@ -1830,7 +1830,7 @@ mptctl_mpt_command (unsigned long arg) ...@@ -1830,7 +1830,7 @@ mptctl_mpt_command (unsigned long arg)
if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_command))) { if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_command))) {
printk(KERN_ERR "%s@%d::mptctl_mpt_command - " printk(KERN_ERR "%s@%d::mptctl_mpt_command - "
"Unable to read in mpt_ioctl_command struct @ %p\n", "Unable to read in mpt_ioctl_command struct @ %p\n",
__FILE__, __LINE__, (void*)uarg); __FILE__, __LINE__, uarg);
return -EFAULT; return -EFAULT;
} }
...@@ -1841,7 +1841,7 @@ mptctl_mpt_command (unsigned long arg) ...@@ -1841,7 +1841,7 @@ mptctl_mpt_command (unsigned long arg)
return -ENODEV; return -ENODEV;
} }
rc = mptctl_do_mpt_command (karg, (char *) &uarg->MF, 0); rc = mptctl_do_mpt_command (karg, &uarg->MF);
return rc; return rc;
} }
...@@ -1859,7 +1859,7 @@ mptctl_mpt_command (unsigned long arg) ...@@ -1859,7 +1859,7 @@ mptctl_mpt_command (unsigned long arg)
* -EPERM if SCSI I/O and target is untagged * -EPERM if SCSI I/O and target is untagged
*/ */
static int static int
mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local) mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr)
{ {
MPT_ADAPTER *ioc; MPT_ADAPTER *ioc;
MPT_FRAME_HDR *mf = NULL; MPT_FRAME_HDR *mf = NULL;
...@@ -1923,23 +1923,15 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local) ...@@ -1923,23 +1923,15 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local)
/* Copy the request frame /* Copy the request frame
* Reset the saved message context. * Reset the saved message context.
* Request frame in user space
*/ */
if (local) { if (copy_from_user(mf, mfPtr, karg.dataSgeOffset * 4)) {
/* Request frame in kernel space
*/
memcpy((char *)mf, (char *) mfPtr, karg.dataSgeOffset * 4);
} else {
/* Request frame in user space
*/
if (copy_from_user((char *)mf, (char *) mfPtr,
karg.dataSgeOffset * 4)){
printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - "
"Unable to read MF from mpt_ioctl_command struct @ %p\n", "Unable to read MF from mpt_ioctl_command struct @ %p\n",
__FILE__, __LINE__, (void*)mfPtr); __FILE__, __LINE__, mfPtr);
rc = -EFAULT; rc = -EFAULT;
goto done_free_mem; goto done_free_mem;
} }
}
hdr->MsgContext = cpu_to_le32(msgContext); hdr->MsgContext = cpu_to_le32(msgContext);
...@@ -2220,7 +2212,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local) ...@@ -2220,7 +2212,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local)
"%s@%d::mptctl_do_mpt_command - Unable " "%s@%d::mptctl_do_mpt_command - Unable "
"to read user data " "to read user data "
"struct @ %p\n", "struct @ %p\n",
__FILE__, __LINE__,(void*)karg.dataOutBufPtr); __FILE__, __LINE__,karg.dataOutBufPtr);
rc = -EFAULT; rc = -EFAULT;
goto done_free_mem; goto done_free_mem;
} }
...@@ -2321,12 +2313,12 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local) ...@@ -2321,12 +2313,12 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local)
} }
if (sz > 0) { if (sz > 0) {
if (copy_to_user((char *)karg.replyFrameBufPtr, if (copy_to_user(karg.replyFrameBufPtr,
&ioc->ioctl->ReplyFrame, sz)){ &ioc->ioctl->ReplyFrame, sz)){
printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - "
"Unable to write out reply frame %p\n", "Unable to write out reply frame %p\n",
__FILE__, __LINE__, (void*)karg.replyFrameBufPtr); __FILE__, __LINE__, karg.replyFrameBufPtr);
rc = -ENODATA; rc = -ENODATA;
goto done_free_mem; goto done_free_mem;
} }
...@@ -2338,11 +2330,11 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local) ...@@ -2338,11 +2330,11 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local)
if (ioc->ioctl->status & MPT_IOCTL_STATUS_SENSE_VALID) { if (ioc->ioctl->status & MPT_IOCTL_STATUS_SENSE_VALID) {
sz = min(karg.maxSenseBytes, MPT_SENSE_BUFFER_SIZE); sz = min(karg.maxSenseBytes, MPT_SENSE_BUFFER_SIZE);
if (sz > 0) { if (sz > 0) {
if (copy_to_user((char *)karg.senseDataPtr, ioc->ioctl->sense, sz)) { if (copy_to_user(karg.senseDataPtr, ioc->ioctl->sense, sz)) {
printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - "
"Unable to write sense data to user %p\n", "Unable to write sense data to user %p\n",
__FILE__, __LINE__, __FILE__, __LINE__,
(void*)karg.senseDataPtr); karg.senseDataPtr);
rc = -ENODATA; rc = -ENODATA;
goto done_free_mem; goto done_free_mem;
} }
...@@ -2355,12 +2347,12 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local) ...@@ -2355,12 +2347,12 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local)
if ((ioc->ioctl->status & MPT_IOCTL_STATUS_COMMAND_GOOD) && if ((ioc->ioctl->status & MPT_IOCTL_STATUS_COMMAND_GOOD) &&
(karg.dataInSize > 0) && (bufIn.kptr)) { (karg.dataInSize > 0) && (bufIn.kptr)) {
if (copy_to_user((char *)karg.dataInBufPtr, if (copy_to_user(karg.dataInBufPtr,
bufIn.kptr, karg.dataInSize)) { bufIn.kptr, karg.dataInSize)) {
printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - "
"Unable to write data to user %p\n", "Unable to write data to user %p\n",
__FILE__, __LINE__, __FILE__, __LINE__,
(void*)karg.dataInBufPtr); karg.dataInBufPtr);
rc = -ENODATA; rc = -ENODATA;
} }
} }
...@@ -2413,7 +2405,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local) ...@@ -2413,7 +2405,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local)
static int static int
mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size)
{ {
hp_host_info_t *uarg = (hp_host_info_t *) arg; hp_host_info_t __user *uarg = (void __user *) arg;
MPT_ADAPTER *ioc; MPT_ADAPTER *ioc;
struct pci_dev *pdev; struct pci_dev *pdev;
char *pbuf; char *pbuf;
...@@ -2437,7 +2429,7 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) ...@@ -2437,7 +2429,7 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size)
if (copy_from_user(&karg, uarg, sizeof(hp_host_info_t))) { if (copy_from_user(&karg, uarg, sizeof(hp_host_info_t))) {
printk(KERN_ERR "%s@%d::mptctl_hp_host_info - " printk(KERN_ERR "%s@%d::mptctl_hp_host_info - "
"Unable to read in hp_host_info struct @ %p\n", "Unable to read in hp_host_info struct @ %p\n",
__FILE__, __LINE__, (void*)uarg); __FILE__, __LINE__, uarg);
return -EFAULT; return -EFAULT;
} }
...@@ -2576,11 +2568,10 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) ...@@ -2576,11 +2568,10 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size)
/* Copy the data from kernel memory to user memory /* Copy the data from kernel memory to user memory
*/ */
if (copy_to_user((char *)arg, &karg, if (copy_to_user((char __user *)arg, &karg, sizeof(hp_host_info_t))) {
sizeof(hp_host_info_t))) {
printk(KERN_ERR "%s@%d::mptctl_hpgethostinfo - " printk(KERN_ERR "%s@%d::mptctl_hpgethostinfo - "
"Unable to write out hp_host_info @ %p\n", "Unable to write out hp_host_info @ %p\n",
__FILE__, __LINE__, (void*)uarg); __FILE__, __LINE__, uarg);
return -EFAULT; return -EFAULT;
} }
...@@ -2602,7 +2593,7 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) ...@@ -2602,7 +2593,7 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size)
static int static int
mptctl_hp_targetinfo(unsigned long arg) mptctl_hp_targetinfo(unsigned long arg)
{ {
hp_target_info_t *uarg = (hp_target_info_t *) arg; hp_target_info_t __user *uarg = (void __user *) arg;
SCSIDevicePage0_t *pg0_alloc; SCSIDevicePage0_t *pg0_alloc;
SCSIDevicePage3_t *pg3_alloc; SCSIDevicePage3_t *pg3_alloc;
MPT_ADAPTER *ioc; MPT_ADAPTER *ioc;
...@@ -2619,7 +2610,7 @@ mptctl_hp_targetinfo(unsigned long arg) ...@@ -2619,7 +2610,7 @@ mptctl_hp_targetinfo(unsigned long arg)
if (copy_from_user(&karg, uarg, sizeof(hp_target_info_t))) { if (copy_from_user(&karg, uarg, sizeof(hp_target_info_t))) {
printk(KERN_ERR "%s@%d::mptctl_hp_targetinfo - " printk(KERN_ERR "%s@%d::mptctl_hp_targetinfo - "
"Unable to read in hp_host_targetinfo struct @ %p\n", "Unable to read in hp_host_targetinfo struct @ %p\n",
__FILE__, __LINE__, (void*)uarg); __FILE__, __LINE__, uarg);
return -EFAULT; return -EFAULT;
} }
...@@ -2727,10 +2718,10 @@ mptctl_hp_targetinfo(unsigned long arg) ...@@ -2727,10 +2718,10 @@ mptctl_hp_targetinfo(unsigned long arg)
/* Copy the data from kernel memory to user memory /* Copy the data from kernel memory to user memory
*/ */
if (copy_to_user((char *)arg, &karg, sizeof(hp_target_info_t))) { if (copy_to_user((char __user *)arg, &karg, sizeof(hp_target_info_t))) {
printk(KERN_ERR "%s@%d::mptctl_hp_target_info - " printk(KERN_ERR "%s@%d::mptctl_hp_target_info - "
"Unable to write out mpt_ioctl_targetinfo struct @ %p\n", "Unable to write out mpt_ioctl_targetinfo struct @ %p\n",
__FILE__, __LINE__, (void*)uarg); __FILE__, __LINE__, uarg);
return -EFAULT; return -EFAULT;
} }
...@@ -2817,7 +2808,7 @@ compat_mptfwxfer_ioctl(unsigned int fd, unsigned int cmd, ...@@ -2817,7 +2808,7 @@ compat_mptfwxfer_ioctl(unsigned int fd, unsigned int cmd,
kfw.iocnum = iocnum; kfw.iocnum = iocnum;
kfw.fwlen = kfw32.fwlen; kfw.fwlen = kfw32.fwlen;
kfw.bufp = (void *)(unsigned long)kfw32.bufp; kfw.bufp = compat_ptr(kfw32.bufp);
ret = mptctl_do_fw_download(kfw.iocnum, kfw.bufp, kfw.fwlen); ret = mptctl_do_fw_download(kfw.iocnum, kfw.bufp, kfw.fwlen);
...@@ -2873,7 +2864,7 @@ compat_mpt_command(unsigned int fd, unsigned int cmd, ...@@ -2873,7 +2864,7 @@ compat_mpt_command(unsigned int fd, unsigned int cmd,
/* Pass new structure to do_mpt_command /* Pass new structure to do_mpt_command
*/ */
ret = mptctl_do_mpt_command (karg, (char *) &uarg->MF, 0); ret = mptctl_do_mpt_command (karg, &uarg->MF);
up(&mptctl_syscall_sem_ioc[iocp->id]); up(&mptctl_syscall_sem_ioc[iocp->id]);
......
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
struct mpt_fw_xfer { struct mpt_fw_xfer {
unsigned int iocnum; /* IOC unit number */ unsigned int iocnum; /* IOC unit number */
unsigned int fwlen; unsigned int fwlen;
void *bufp; /* Pointer to firmware buffer */ void __user *bufp; /* Pointer to firmware buffer */
}; };
#if defined(__KERNEL__) && defined(CONFIG_COMPAT) #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
...@@ -332,10 +332,10 @@ typedef struct mpt_ioctl_replace_fw { ...@@ -332,10 +332,10 @@ typedef struct mpt_ioctl_replace_fw {
struct mpt_ioctl_command { struct mpt_ioctl_command {
mpt_ioctl_header hdr; mpt_ioctl_header hdr;
int timeout; /* optional (seconds) */ int timeout; /* optional (seconds) */
char *replyFrameBufPtr; char __user *replyFrameBufPtr;
char *dataInBufPtr; char __user *dataInBufPtr;
char *dataOutBufPtr; char __user *dataOutBufPtr;
char *senseDataPtr; char __user *senseDataPtr;
int maxReplyBytes; int maxReplyBytes;
int dataInSize; int dataInSize;
int dataOutSize; int dataOutSize;
......
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