Skip to content

Commit a2e2c69

Browse files
Alexander ViroLinus Torvalds
authored andcommitted
[PATCH] sparse: slip.c annotation
1 parent 3ca64eb commit a2e2c69

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

drivers/net/slip.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,7 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
11381138
{
11391139
struct slip *sl = (struct slip *) tty->disc_data;
11401140
unsigned int tmp;
1141+
int __user *p = (int __user *)arg;
11411142

11421143
/* First make sure we're connected. */
11431144
if (!sl || sl->magic != SLIP_MAGIC) {
@@ -1147,17 +1148,17 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
11471148
switch(cmd) {
11481149
case SIOCGIFNAME:
11491150
tmp = strlen(sl->dev->name) + 1;
1150-
if (copy_to_user((void *)arg, sl->dev->name, tmp))
1151+
if (copy_to_user((void __user *)arg, sl->dev->name, tmp))
11511152
return -EFAULT;
11521153
return 0;
11531154

11541155
case SIOCGIFENCAP:
1155-
if (put_user(sl->mode, (int *)arg))
1156+
if (put_user(sl->mode, p))
11561157
return -EFAULT;
11571158
return 0;
11581159

11591160
case SIOCSIFENCAP:
1160-
if (get_user(tmp,(int *)arg))
1161+
if (get_user(tmp, p))
11611162
return -EFAULT;
11621163
#ifndef SL_INCLUDE_CSLIP
11631164
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
11851186
#ifdef CONFIG_SLIP_SMART
11861187
/* VSV changes start here */
11871188
case SIOCSKEEPALIVE:
1188-
if (get_user(tmp,(int *)arg))
1189+
if (get_user(tmp, p))
11891190
return -EFAULT;
11901191
if (tmp > 255) /* max for unchar */
11911192
return -EINVAL;
@@ -1205,12 +1206,12 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
12051206
return 0;
12061207

12071208
case SIOCGKEEPALIVE:
1208-
if (put_user(sl->keepalive, (int *)arg))
1209+
if (put_user(sl->keepalive, p))
12091210
return -EFAULT;
12101211
return 0;
12111212

12121213
case SIOCSOUTFILL:
1213-
if (get_user(tmp,(int *)arg))
1214+
if (get_user(tmp, p))
12141215
return -EFAULT;
12151216
if (tmp > 255) /* max for unchar */
12161217
return -EINVAL;
@@ -1229,7 +1230,7 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
12291230
return 0;
12301231

12311232
case SIOCGOUTFILL:
1232-
if (put_user(sl->outfill, (int *)arg))
1233+
if (put_user(sl->outfill, p))
12331234
return -EFAULT;
12341235
return 0;
12351236
/* VSV changes end */
@@ -1254,6 +1255,7 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
12541255
static int sl_ioctl(struct net_device *dev,struct ifreq *rq,int cmd)
12551256
{
12561257
struct slip *sl = (struct slip*)(dev->priv);
1258+
unsigned long *p = (unsigned long *)&rq->ifr_ifru;
12571259

12581260
if (sl == NULL) /* Allocation failed ?? */
12591261
return -ENODEV;
@@ -1268,11 +1270,11 @@ static int sl_ioctl(struct net_device *dev,struct ifreq *rq,int cmd)
12681270
switch(cmd){
12691271
case SIOCSKEEPALIVE:
12701272
/* max for unchar */
1271-
if (((unsigned int)((unsigned long)rq->ifr_data)) > 255) {
1273+
if ((unsigned)*p > 255) {
12721274
spin_unlock_bh(&sl->lock);
12731275
return -EINVAL;
12741276
}
1275-
sl->keepalive = (unchar) ((unsigned long)rq->ifr_data);
1277+
sl->keepalive = (unchar) *p;
12761278
if (sl->keepalive != 0) {
12771279
sl->keepalive_timer.expires=jiffies+sl->keepalive*HZ;
12781280
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)
12831285
break;
12841286

12851287
case SIOCGKEEPALIVE:
1286-
rq->ifr_data=(caddr_t)((unsigned long)sl->keepalive);
1288+
*p = sl->keepalive;
12871289
break;
12881290

12891291
case SIOCSOUTFILL:
1290-
if (((unsigned)((unsigned long)rq->ifr_data)) > 255) { /* max for unchar */
1292+
if ((unsigned)*p > 255) { /* max for unchar */
12911293
spin_unlock_bh(&sl->lock);
12921294
return -EINVAL;
12931295
}
1294-
if ((sl->outfill = (unchar)((unsigned long) rq->ifr_data)) != 0){
1296+
if ((sl->outfill = (unchar)*p) != 0){
12951297
mod_timer(&sl->outfill_timer, jiffies+sl->outfill*HZ);
12961298
set_bit(SLF_OUTWAIT, &sl->flags);
12971299
} else {
@@ -1300,7 +1302,7 @@ static int sl_ioctl(struct net_device *dev,struct ifreq *rq,int cmd)
13001302
break;
13011303

13021304
case SIOCGOUTFILL:
1303-
rq->ifr_data=(caddr_t)((unsigned long)sl->outfill);
1305+
*p = sl->outfill;
13041306
break;
13051307

13061308
case SIOCSLEASE:
@@ -1312,12 +1314,12 @@ static int sl_ioctl(struct net_device *dev,struct ifreq *rq,int cmd)
13121314
return -EPERM;
13131315
}
13141316
sl->leased = 0;
1315-
if ((unsigned long)rq->ifr_data)
1317+
if (*p)
13161318
sl->leased = 1;
13171319
break;
13181320

13191321
case SIOCGLEASE:
1320-
rq->ifr_data=(caddr_t)((unsigned long)sl->leased);
1322+
*p = sl->leased;
13211323
};
13221324
spin_unlock_bh(&sl->lock);
13231325
return 0;

0 commit comments

Comments
 (0)