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

[PATCH] sparse: ipmi annotation

parent 0d944920
...@@ -231,6 +231,7 @@ static int ipmi_ioctl(struct inode *inode, ...@@ -231,6 +231,7 @@ static int ipmi_ioctl(struct inode *inode,
{ {
int rv = -EINVAL; int rv = -EINVAL;
struct ipmi_file_private *priv = file->private_data; struct ipmi_file_private *priv = file->private_data;
void __user *arg = (void __user *)data;
switch (cmd) switch (cmd)
{ {
...@@ -238,7 +239,7 @@ static int ipmi_ioctl(struct inode *inode, ...@@ -238,7 +239,7 @@ static int ipmi_ioctl(struct inode *inode,
{ {
struct ipmi_req req; struct ipmi_req req;
if (copy_from_user(&req, (void *) data, sizeof(req))) { if (copy_from_user(&req, arg, sizeof(req))) {
rv = -EFAULT; rv = -EFAULT;
break; break;
} }
...@@ -254,7 +255,7 @@ static int ipmi_ioctl(struct inode *inode, ...@@ -254,7 +255,7 @@ static int ipmi_ioctl(struct inode *inode,
{ {
struct ipmi_req_settime req; struct ipmi_req_settime req;
if (copy_from_user(&req, (void *) data, sizeof(req))) { if (copy_from_user(&req, arg, sizeof(req))) {
rv = -EFAULT; rv = -EFAULT;
break; break;
} }
...@@ -277,7 +278,7 @@ static int ipmi_ioctl(struct inode *inode, ...@@ -277,7 +278,7 @@ static int ipmi_ioctl(struct inode *inode,
rv = 0; rv = 0;
if (copy_from_user(&rsp, (void *) data, sizeof(rsp))) { if (copy_from_user(&rsp, arg, sizeof(rsp))) {
rv = -EFAULT; rv = -EFAULT;
break; break;
} }
...@@ -344,7 +345,7 @@ static int ipmi_ioctl(struct inode *inode, ...@@ -344,7 +345,7 @@ static int ipmi_ioctl(struct inode *inode,
rsp.msg.data_len = 0; rsp.msg.data_len = 0;
} }
if (copy_to_user((void *) data, &rsp, sizeof(rsp))) { if (copy_to_user(arg, &rsp, sizeof(rsp))) {
rv = -EFAULT; rv = -EFAULT;
goto recv_putback_on_err; goto recv_putback_on_err;
} }
...@@ -371,7 +372,7 @@ static int ipmi_ioctl(struct inode *inode, ...@@ -371,7 +372,7 @@ static int ipmi_ioctl(struct inode *inode,
{ {
struct ipmi_cmdspec val; struct ipmi_cmdspec val;
if (copy_from_user(&val, (void *) data, sizeof(val))) { if (copy_from_user(&val, arg, sizeof(val))) {
rv = -EFAULT; rv = -EFAULT;
break; break;
} }
...@@ -384,7 +385,7 @@ static int ipmi_ioctl(struct inode *inode, ...@@ -384,7 +385,7 @@ static int ipmi_ioctl(struct inode *inode,
{ {
struct ipmi_cmdspec val; struct ipmi_cmdspec val;
if (copy_from_user(&val, (void *) data, sizeof(val))) { if (copy_from_user(&val, arg, sizeof(val))) {
rv = -EFAULT; rv = -EFAULT;
break; break;
} }
...@@ -397,7 +398,7 @@ static int ipmi_ioctl(struct inode *inode, ...@@ -397,7 +398,7 @@ static int ipmi_ioctl(struct inode *inode,
{ {
int val; int val;
if (copy_from_user(&val, (void *) data, sizeof(val))) { if (copy_from_user(&val, arg, sizeof(val))) {
rv = -EFAULT; rv = -EFAULT;
break; break;
} }
...@@ -410,7 +411,7 @@ static int ipmi_ioctl(struct inode *inode, ...@@ -410,7 +411,7 @@ static int ipmi_ioctl(struct inode *inode,
{ {
unsigned int val; unsigned int val;
if (copy_from_user(&val, (void *) data, sizeof(val))) { if (copy_from_user(&val, arg, sizeof(val))) {
rv = -EFAULT; rv = -EFAULT;
break; break;
} }
...@@ -426,7 +427,7 @@ static int ipmi_ioctl(struct inode *inode, ...@@ -426,7 +427,7 @@ static int ipmi_ioctl(struct inode *inode,
val = ipmi_get_my_address(priv->user); val = ipmi_get_my_address(priv->user);
if (copy_to_user((void *) data, &val, sizeof(val))) { if (copy_to_user(arg, &val, sizeof(val))) {
rv = -EFAULT; rv = -EFAULT;
break; break;
} }
...@@ -438,7 +439,7 @@ static int ipmi_ioctl(struct inode *inode, ...@@ -438,7 +439,7 @@ static int ipmi_ioctl(struct inode *inode,
{ {
unsigned int val; unsigned int val;
if (copy_from_user(&val, (void *) data, sizeof(val))) { if (copy_from_user(&val, arg, sizeof(val))) {
rv = -EFAULT; rv = -EFAULT;
break; break;
} }
...@@ -454,7 +455,7 @@ static int ipmi_ioctl(struct inode *inode, ...@@ -454,7 +455,7 @@ static int ipmi_ioctl(struct inode *inode,
val = ipmi_get_my_LUN(priv->user); val = ipmi_get_my_LUN(priv->user);
if (copy_to_user((void *) data, &val, sizeof(val))) { if (copy_to_user(arg, &val, sizeof(val))) {
rv = -EFAULT; rv = -EFAULT;
break; break;
} }
...@@ -465,7 +466,7 @@ static int ipmi_ioctl(struct inode *inode, ...@@ -465,7 +466,7 @@ static int ipmi_ioctl(struct inode *inode,
{ {
struct ipmi_timing_parms parms; struct ipmi_timing_parms parms;
if (copy_from_user(&parms, (void *) data, sizeof(parms))) { if (copy_from_user(&parms, arg, sizeof(parms))) {
rv = -EFAULT; rv = -EFAULT;
break; break;
} }
...@@ -483,7 +484,7 @@ static int ipmi_ioctl(struct inode *inode, ...@@ -483,7 +484,7 @@ static int ipmi_ioctl(struct inode *inode,
parms.retries = priv->default_retries; parms.retries = priv->default_retries;
parms.retry_time_ms = priv->default_retry_time_ms; parms.retry_time_ms = priv->default_retry_time_ms;
if (copy_to_user((void *) data, &parms, sizeof(parms))) { if (copy_to_user(arg, &parms, sizeof(parms))) {
rv = -EFAULT; rv = -EFAULT;
break; break;
} }
......
...@@ -515,40 +515,37 @@ static struct watchdog_info ident= ...@@ -515,40 +515,37 @@ static struct watchdog_info ident=
static int ipmi_ioctl(struct inode *inode, struct file *file, static int ipmi_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
void __user *argp = (void __user *)arg;
int i; int i;
int val; int val;
switch(cmd) { switch(cmd) {
case WDIOC_GETSUPPORT: case WDIOC_GETSUPPORT:
i = copy_to_user((void*)arg, &ident, sizeof(ident)); i = copy_to_user(argp, &ident, sizeof(ident));
return i ? -EFAULT : 0; return i ? -EFAULT : 0;
case WDIOC_SETTIMEOUT: case WDIOC_SETTIMEOUT:
i = copy_from_user(&val, (void *) arg, sizeof(int)); i = copy_from_user(&val, argp, sizeof(int));
if (i) if (i)
return -EFAULT; return -EFAULT;
timeout = val; timeout = val;
return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY); return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY);
case WDIOC_GETTIMEOUT: case WDIOC_GETTIMEOUT:
i = copy_to_user((void *) arg, i = copy_to_user(argp, &timeout, sizeof(timeout));
&timeout,
sizeof(timeout));
if (i) if (i)
return -EFAULT; return -EFAULT;
return 0; return 0;
case WDIOC_SET_PRETIMEOUT: case WDIOC_SET_PRETIMEOUT:
i = copy_from_user(&val, (void *) arg, sizeof(int)); i = copy_from_user(&val, argp, sizeof(int));
if (i) if (i)
return -EFAULT; return -EFAULT;
pretimeout = val; pretimeout = val;
return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY); return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY);
case WDIOC_GET_PRETIMEOUT: case WDIOC_GET_PRETIMEOUT:
i = copy_to_user((void *) arg, i = copy_to_user(argp, &pretimeout, sizeof(pretimeout));
&pretimeout,
sizeof(pretimeout));
if (i) if (i)
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -557,7 +554,7 @@ static int ipmi_ioctl(struct inode *inode, struct file *file, ...@@ -557,7 +554,7 @@ static int ipmi_ioctl(struct inode *inode, struct file *file,
return ipmi_heartbeat(); return ipmi_heartbeat();
case WDIOC_SETOPTIONS: case WDIOC_SETOPTIONS:
i = copy_from_user(&val, (void *) arg, sizeof(int)); i = copy_from_user(&val, argp, sizeof(int));
if (i) if (i)
return -EFAULT; return -EFAULT;
if (val & WDIOS_DISABLECARD) if (val & WDIOS_DISABLECARD)
...@@ -576,7 +573,7 @@ static int ipmi_ioctl(struct inode *inode, struct file *file, ...@@ -576,7 +573,7 @@ static int ipmi_ioctl(struct inode *inode, struct file *file,
case WDIOC_GETSTATUS: case WDIOC_GETSTATUS:
val = 0; val = 0;
i = copy_to_user((void *) arg, &val, sizeof(val)); i = copy_to_user(argp, &val, sizeof(val));
if (i) if (i)
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -587,7 +584,7 @@ static int ipmi_ioctl(struct inode *inode, struct file *file, ...@@ -587,7 +584,7 @@ static int ipmi_ioctl(struct inode *inode, struct file *file,
} }
static ssize_t ipmi_write(struct file *file, static ssize_t ipmi_write(struct file *file,
const char *buf, const char __user *buf,
size_t len, size_t len,
loff_t *ppos) loff_t *ppos)
{ {
...@@ -607,7 +604,7 @@ static ssize_t ipmi_write(struct file *file, ...@@ -607,7 +604,7 @@ static ssize_t ipmi_write(struct file *file,
} }
static ssize_t ipmi_read(struct file *file, static ssize_t ipmi_read(struct file *file,
char *buf, char __user *buf,
size_t count, size_t count,
loff_t *ppos) loff_t *ppos)
{ {
......
...@@ -488,7 +488,7 @@ int ipmi_addr_equal(struct ipmi_addr *addr1, struct ipmi_addr *addr2); ...@@ -488,7 +488,7 @@ int ipmi_addr_equal(struct ipmi_addr *addr1, struct ipmi_addr *addr2);
/* Messages sent to the interface are this format. */ /* Messages sent to the interface are this format. */
struct ipmi_req struct ipmi_req
{ {
unsigned char *addr; /* Address to send the message to. */ unsigned char __user *addr; /* Address to send the message to. */
unsigned int addr_len; unsigned int addr_len;
long msgid; /* The sequence number for the message. This long msgid; /* The sequence number for the message. This
...@@ -539,7 +539,7 @@ struct ipmi_recv ...@@ -539,7 +539,7 @@ struct ipmi_recv
int recv_type; /* Is this a command, response or an int recv_type; /* Is this a command, response or an
asyncronous event. */ asyncronous event. */
unsigned char *addr; /* Address the message was from is put unsigned char __user *addr; /* Address the message was from is put
here. The caller must supply the here. The caller must supply the
memory. */ memory. */
unsigned int addr_len; /* The size of the address buffer. unsigned int addr_len; /* The size of the address buffer.
......
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