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

[PATCH] sparse: slip.c annotation

parent 3ca64eb7
...@@ -1138,6 +1138,7 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm ...@@ -1138,6 +1138,7 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
{ {
struct slip *sl = (struct slip *) tty->disc_data; struct slip *sl = (struct slip *) tty->disc_data;
unsigned int tmp; unsigned int tmp;
int __user *p = (int __user *)arg;
/* First make sure we're connected. */ /* First make sure we're connected. */
if (!sl || sl->magic != SLIP_MAGIC) { if (!sl || sl->magic != SLIP_MAGIC) {
...@@ -1147,17 +1148,17 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm ...@@ -1147,17 +1148,17 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
switch(cmd) { switch(cmd) {
case SIOCGIFNAME: case SIOCGIFNAME:
tmp = strlen(sl->dev->name) + 1; tmp = strlen(sl->dev->name) + 1;
if (copy_to_user((void *)arg, sl->dev->name, tmp)) if (copy_to_user((void __user *)arg, sl->dev->name, tmp))
return -EFAULT; return -EFAULT;
return 0; return 0;
case SIOCGIFENCAP: case SIOCGIFENCAP:
if (put_user(sl->mode, (int *)arg)) if (put_user(sl->mode, p))
return -EFAULT; return -EFAULT;
return 0; return 0;
case SIOCSIFENCAP: case SIOCSIFENCAP:
if (get_user(tmp,(int *)arg)) if (get_user(tmp, p))
return -EFAULT; return -EFAULT;
#ifndef SL_INCLUDE_CSLIP #ifndef SL_INCLUDE_CSLIP
if (tmp & (SL_MODE_CSLIP|SL_MODE_ADAPTIVE)) { if (tmp & (SL_MODE_CSLIP|SL_MODE_ADAPTIVE)) {
...@@ -1185,7 +1186,7 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm ...@@ -1185,7 +1186,7 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
#ifdef CONFIG_SLIP_SMART #ifdef CONFIG_SLIP_SMART
/* VSV changes start here */ /* VSV changes start here */
case SIOCSKEEPALIVE: case SIOCSKEEPALIVE:
if (get_user(tmp,(int *)arg)) if (get_user(tmp, p))
return -EFAULT; return -EFAULT;
if (tmp > 255) /* max for unchar */ if (tmp > 255) /* max for unchar */
return -EINVAL; return -EINVAL;
...@@ -1205,12 +1206,12 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm ...@@ -1205,12 +1206,12 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
return 0; return 0;
case SIOCGKEEPALIVE: case SIOCGKEEPALIVE:
if (put_user(sl->keepalive, (int *)arg)) if (put_user(sl->keepalive, p))
return -EFAULT; return -EFAULT;
return 0; return 0;
case SIOCSOUTFILL: case SIOCSOUTFILL:
if (get_user(tmp,(int *)arg)) if (get_user(tmp, p))
return -EFAULT; return -EFAULT;
if (tmp > 255) /* max for unchar */ if (tmp > 255) /* max for unchar */
return -EINVAL; return -EINVAL;
...@@ -1229,7 +1230,7 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm ...@@ -1229,7 +1230,7 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
return 0; return 0;
case SIOCGOUTFILL: case SIOCGOUTFILL:
if (put_user(sl->outfill, (int *)arg)) if (put_user(sl->outfill, p))
return -EFAULT; return -EFAULT;
return 0; return 0;
/* VSV changes end */ /* VSV changes end */
...@@ -1254,6 +1255,7 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm ...@@ -1254,6 +1255,7 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
static int sl_ioctl(struct net_device *dev,struct ifreq *rq,int cmd) static int sl_ioctl(struct net_device *dev,struct ifreq *rq,int cmd)
{ {
struct slip *sl = (struct slip*)(dev->priv); struct slip *sl = (struct slip*)(dev->priv);
unsigned long *p = (unsigned long *)&rq->ifr_ifru;
if (sl == NULL) /* Allocation failed ?? */ if (sl == NULL) /* Allocation failed ?? */
return -ENODEV; return -ENODEV;
...@@ -1268,11 +1270,11 @@ static int sl_ioctl(struct net_device *dev,struct ifreq *rq,int cmd) ...@@ -1268,11 +1270,11 @@ static int sl_ioctl(struct net_device *dev,struct ifreq *rq,int cmd)
switch(cmd){ switch(cmd){
case SIOCSKEEPALIVE: case SIOCSKEEPALIVE:
/* max for unchar */ /* max for unchar */
if (((unsigned int)((unsigned long)rq->ifr_data)) > 255) { if ((unsigned)*p > 255) {
spin_unlock_bh(&sl->lock); spin_unlock_bh(&sl->lock);
return -EINVAL; return -EINVAL;
} }
sl->keepalive = (unchar) ((unsigned long)rq->ifr_data); sl->keepalive = (unchar) *p;
if (sl->keepalive != 0) { if (sl->keepalive != 0) {
sl->keepalive_timer.expires=jiffies+sl->keepalive*HZ; sl->keepalive_timer.expires=jiffies+sl->keepalive*HZ;
mod_timer(&sl->keepalive_timer, jiffies+sl->keepalive*HZ); mod_timer(&sl->keepalive_timer, jiffies+sl->keepalive*HZ);
...@@ -1283,15 +1285,15 @@ static int sl_ioctl(struct net_device *dev,struct ifreq *rq,int cmd) ...@@ -1283,15 +1285,15 @@ static int sl_ioctl(struct net_device *dev,struct ifreq *rq,int cmd)
break; break;
case SIOCGKEEPALIVE: case SIOCGKEEPALIVE:
rq->ifr_data=(caddr_t)((unsigned long)sl->keepalive); *p = sl->keepalive;
break; break;
case SIOCSOUTFILL: case SIOCSOUTFILL:
if (((unsigned)((unsigned long)rq->ifr_data)) > 255) { /* max for unchar */ if ((unsigned)*p > 255) { /* max for unchar */
spin_unlock_bh(&sl->lock); spin_unlock_bh(&sl->lock);
return -EINVAL; return -EINVAL;
} }
if ((sl->outfill = (unchar)((unsigned long) rq->ifr_data)) != 0){ if ((sl->outfill = (unchar)*p) != 0){
mod_timer(&sl->outfill_timer, jiffies+sl->outfill*HZ); mod_timer(&sl->outfill_timer, jiffies+sl->outfill*HZ);
set_bit(SLF_OUTWAIT, &sl->flags); set_bit(SLF_OUTWAIT, &sl->flags);
} else { } else {
...@@ -1300,7 +1302,7 @@ static int sl_ioctl(struct net_device *dev,struct ifreq *rq,int cmd) ...@@ -1300,7 +1302,7 @@ static int sl_ioctl(struct net_device *dev,struct ifreq *rq,int cmd)
break; break;
case SIOCGOUTFILL: case SIOCGOUTFILL:
rq->ifr_data=(caddr_t)((unsigned long)sl->outfill); *p = sl->outfill;
break; break;
case SIOCSLEASE: case SIOCSLEASE:
...@@ -1312,12 +1314,12 @@ static int sl_ioctl(struct net_device *dev,struct ifreq *rq,int cmd) ...@@ -1312,12 +1314,12 @@ static int sl_ioctl(struct net_device *dev,struct ifreq *rq,int cmd)
return -EPERM; return -EPERM;
} }
sl->leased = 0; sl->leased = 0;
if ((unsigned long)rq->ifr_data) if (*p)
sl->leased = 1; sl->leased = 1;
break; break;
case SIOCGLEASE: case SIOCGLEASE:
rq->ifr_data=(caddr_t)((unsigned long)sl->leased); *p = sl->leased;
}; };
spin_unlock_bh(&sl->lock); spin_unlock_bh(&sl->lock);
return 0; return 0;
......
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