@@ -1102,22 +1102,20 @@ static int usbdev_release(struct inode *inode, struct file *file)
1102
1102
return 0 ;
1103
1103
}
1104
1104
1105
- static int proc_control (struct usb_dev_state * ps , void __user * arg )
1105
+ static int do_proc_control (struct usb_dev_state * ps ,
1106
+ struct usbdevfs_ctrltransfer * ctrl )
1106
1107
{
1107
1108
struct usb_device * dev = ps -> dev ;
1108
- struct usbdevfs_ctrltransfer ctrl ;
1109
1109
unsigned int tmo ;
1110
1110
unsigned char * tbuf ;
1111
1111
unsigned wLength ;
1112
1112
int i , pipe , ret ;
1113
1113
1114
- if (copy_from_user (& ctrl , arg , sizeof (ctrl )))
1115
- return - EFAULT ;
1116
- ret = check_ctrlrecip (ps , ctrl .bRequestType , ctrl .bRequest ,
1117
- ctrl .wIndex );
1114
+ ret = check_ctrlrecip (ps , ctrl -> bRequestType , ctrl -> bRequest ,
1115
+ ctrl -> wIndex );
1118
1116
if (ret )
1119
1117
return ret ;
1120
- wLength = ctrl . wLength ; /* To suppress 64k PAGE_SIZE warning */
1118
+ wLength = ctrl -> wLength ; /* To suppress 64k PAGE_SIZE warning */
1121
1119
if (wLength > PAGE_SIZE )
1122
1120
return - EINVAL ;
1123
1121
ret = usbfs_increase_memory_usage (PAGE_SIZE + sizeof (struct urb ) +
@@ -1129,52 +1127,52 @@ static int proc_control(struct usb_dev_state *ps, void __user *arg)
1129
1127
ret = - ENOMEM ;
1130
1128
goto done ;
1131
1129
}
1132
- tmo = ctrl . timeout ;
1130
+ tmo = ctrl -> timeout ;
1133
1131
snoop (& dev -> dev , "control urb: bRequestType=%02x "
1134
1132
"bRequest=%02x wValue=%04x "
1135
1133
"wIndex=%04x wLength=%04x\n" ,
1136
- ctrl . bRequestType , ctrl . bRequest , ctrl . wValue ,
1137
- ctrl . wIndex , ctrl . wLength );
1138
- if (ctrl . bRequestType & 0x80 ) {
1134
+ ctrl -> bRequestType , ctrl -> bRequest , ctrl -> wValue ,
1135
+ ctrl -> wIndex , ctrl -> wLength );
1136
+ if (ctrl -> bRequestType & 0x80 ) {
1139
1137
pipe = usb_rcvctrlpipe (dev , 0 );
1140
- snoop_urb (dev , NULL , pipe , ctrl . wLength , tmo , SUBMIT , NULL , 0 );
1138
+ snoop_urb (dev , NULL , pipe , ctrl -> wLength , tmo , SUBMIT , NULL , 0 );
1141
1139
1142
1140
usb_unlock_device (dev );
1143
- i = usb_control_msg (dev , pipe , ctrl . bRequest ,
1144
- ctrl . bRequestType , ctrl . wValue , ctrl . wIndex ,
1145
- tbuf , ctrl . wLength , tmo );
1141
+ i = usb_control_msg (dev , pipe , ctrl -> bRequest ,
1142
+ ctrl -> bRequestType , ctrl -> wValue , ctrl -> wIndex ,
1143
+ tbuf , ctrl -> wLength , tmo );
1146
1144
usb_lock_device (dev );
1147
1145
snoop_urb (dev , NULL , pipe , max (i , 0 ), min (i , 0 ), COMPLETE ,
1148
1146
tbuf , max (i , 0 ));
1149
- if ((i > 0 ) && ctrl . wLength ) {
1150
- if (copy_to_user (ctrl . data , tbuf , i )) {
1147
+ if ((i > 0 ) && ctrl -> wLength ) {
1148
+ if (copy_to_user (ctrl -> data , tbuf , i )) {
1151
1149
ret = - EFAULT ;
1152
1150
goto done ;
1153
1151
}
1154
1152
}
1155
1153
} else {
1156
- if (ctrl . wLength ) {
1157
- if (copy_from_user (tbuf , ctrl . data , ctrl . wLength )) {
1154
+ if (ctrl -> wLength ) {
1155
+ if (copy_from_user (tbuf , ctrl -> data , ctrl -> wLength )) {
1158
1156
ret = - EFAULT ;
1159
1157
goto done ;
1160
1158
}
1161
1159
}
1162
1160
pipe = usb_sndctrlpipe (dev , 0 );
1163
- snoop_urb (dev , NULL , pipe , ctrl . wLength , tmo , SUBMIT ,
1164
- tbuf , ctrl . wLength );
1161
+ snoop_urb (dev , NULL , pipe , ctrl -> wLength , tmo , SUBMIT ,
1162
+ tbuf , ctrl -> wLength );
1165
1163
1166
1164
usb_unlock_device (dev );
1167
- i = usb_control_msg (dev , usb_sndctrlpipe (dev , 0 ), ctrl . bRequest ,
1168
- ctrl . bRequestType , ctrl . wValue , ctrl . wIndex ,
1169
- tbuf , ctrl . wLength , tmo );
1165
+ i = usb_control_msg (dev , usb_sndctrlpipe (dev , 0 ), ctrl -> bRequest ,
1166
+ ctrl -> bRequestType , ctrl -> wValue , ctrl -> wIndex ,
1167
+ tbuf , ctrl -> wLength , tmo );
1170
1168
usb_lock_device (dev );
1171
1169
snoop_urb (dev , NULL , pipe , max (i , 0 ), min (i , 0 ), COMPLETE , NULL , 0 );
1172
1170
}
1173
1171
if (i < 0 && i != - EPIPE ) {
1174
1172
dev_printk (KERN_DEBUG , & dev -> dev , "usbfs: USBDEVFS_CONTROL "
1175
1173
"failed cmd %s rqt %u rq %u len %u ret %d\n" ,
1176
- current -> comm , ctrl . bRequestType , ctrl . bRequest ,
1177
- ctrl . wLength , i );
1174
+ current -> comm , ctrl -> bRequestType , ctrl -> bRequest ,
1175
+ ctrl -> wLength , i );
1178
1176
}
1179
1177
ret = i ;
1180
1178
done :
@@ -1184,30 +1182,37 @@ static int proc_control(struct usb_dev_state *ps, void __user *arg)
1184
1182
return ret ;
1185
1183
}
1186
1184
1187
- static int proc_bulk (struct usb_dev_state * ps , void __user * arg )
1185
+ static int proc_control (struct usb_dev_state * ps , void __user * arg )
1186
+ {
1187
+ struct usbdevfs_ctrltransfer ctrl ;
1188
+
1189
+ if (copy_from_user (& ctrl , arg , sizeof (ctrl )))
1190
+ return - EFAULT ;
1191
+ return do_proc_control (ps , & ctrl );
1192
+ }
1193
+
1194
+ static int do_proc_bulk (struct usb_dev_state * ps ,
1195
+ struct usbdevfs_bulktransfer * bulk )
1188
1196
{
1189
1197
struct usb_device * dev = ps -> dev ;
1190
- struct usbdevfs_bulktransfer bulk ;
1191
1198
unsigned int tmo , len1 , pipe ;
1192
1199
int len2 ;
1193
1200
unsigned char * tbuf ;
1194
1201
int i , ret ;
1195
1202
1196
- if (copy_from_user (& bulk , arg , sizeof (bulk )))
1197
- return - EFAULT ;
1198
- ret = findintfep (ps -> dev , bulk .ep );
1203
+ ret = findintfep (ps -> dev , bulk -> ep );
1199
1204
if (ret < 0 )
1200
1205
return ret ;
1201
1206
ret = checkintf (ps , ret );
1202
1207
if (ret )
1203
1208
return ret ;
1204
- if (bulk . ep & USB_DIR_IN )
1205
- pipe = usb_rcvbulkpipe (dev , bulk . ep & 0x7f );
1209
+ if (bulk -> ep & USB_DIR_IN )
1210
+ pipe = usb_rcvbulkpipe (dev , bulk -> ep & 0x7f );
1206
1211
else
1207
- pipe = usb_sndbulkpipe (dev , bulk . ep & 0x7f );
1208
- if (!usb_maxpacket (dev , pipe , !(bulk . ep & USB_DIR_IN )))
1212
+ pipe = usb_sndbulkpipe (dev , bulk -> ep & 0x7f );
1213
+ if (!usb_maxpacket (dev , pipe , !(bulk -> ep & USB_DIR_IN )))
1209
1214
return - EINVAL ;
1210
- len1 = bulk . len ;
1215
+ len1 = bulk -> len ;
1211
1216
if (len1 >= (INT_MAX - sizeof (struct urb )))
1212
1217
return - EINVAL ;
1213
1218
ret = usbfs_increase_memory_usage (len1 + sizeof (struct urb ));
@@ -1218,8 +1223,8 @@ static int proc_bulk(struct usb_dev_state *ps, void __user *arg)
1218
1223
ret = - ENOMEM ;
1219
1224
goto done ;
1220
1225
}
1221
- tmo = bulk . timeout ;
1222
- if (bulk . ep & 0x80 ) {
1226
+ tmo = bulk -> timeout ;
1227
+ if (bulk -> ep & 0x80 ) {
1223
1228
snoop_urb (dev , NULL , pipe , len1 , tmo , SUBMIT , NULL , 0 );
1224
1229
1225
1230
usb_unlock_device (dev );
@@ -1228,14 +1233,14 @@ static int proc_bulk(struct usb_dev_state *ps, void __user *arg)
1228
1233
snoop_urb (dev , NULL , pipe , len2 , i , COMPLETE , tbuf , len2 );
1229
1234
1230
1235
if (!i && len2 ) {
1231
- if (copy_to_user (bulk . data , tbuf , len2 )) {
1236
+ if (copy_to_user (bulk -> data , tbuf , len2 )) {
1232
1237
ret = - EFAULT ;
1233
1238
goto done ;
1234
1239
}
1235
1240
}
1236
1241
} else {
1237
1242
if (len1 ) {
1238
- if (copy_from_user (tbuf , bulk . data , len1 )) {
1243
+ if (copy_from_user (tbuf , bulk -> data , len1 )) {
1239
1244
ret = - EFAULT ;
1240
1245
goto done ;
1241
1246
}
@@ -1254,6 +1259,15 @@ static int proc_bulk(struct usb_dev_state *ps, void __user *arg)
1254
1259
return ret ;
1255
1260
}
1256
1261
1262
+ static int proc_bulk (struct usb_dev_state * ps , void __user * arg )
1263
+ {
1264
+ struct usbdevfs_bulktransfer bulk ;
1265
+
1266
+ if (copy_from_user (& bulk , arg , sizeof (bulk )))
1267
+ return - EFAULT ;
1268
+ return do_proc_bulk (ps , & bulk );
1269
+ }
1270
+
1257
1271
static void check_reset_of_active_ep (struct usb_device * udev ,
1258
1272
unsigned int epnum , char * ioctl_name )
1259
1273
{
@@ -2013,33 +2027,31 @@ static int proc_reapurbnonblock(struct usb_dev_state *ps, void __user *arg)
2013
2027
static int proc_control_compat (struct usb_dev_state * ps ,
2014
2028
struct usbdevfs_ctrltransfer32 __user * p32 )
2015
2029
{
2016
- struct usbdevfs_ctrltransfer __user * p ;
2017
- __u32 udata ;
2018
- p = compat_alloc_user_space (sizeof (* p ));
2019
- if (copy_in_user (p , p32 , (sizeof (* p32 ) - sizeof (compat_caddr_t ))) ||
2020
- get_user (udata , & p32 -> data ) ||
2021
- put_user (compat_ptr (udata ), & p -> data ))
2030
+ struct usbdevfs_ctrltransfer ctrl ;
2031
+ u32 udata ;
2032
+
2033
+ if (copy_from_user (& ctrl , p32 , sizeof (* p32 ) - sizeof (compat_caddr_t )) ||
2034
+ get_user (udata , & p32 -> data ))
2022
2035
return - EFAULT ;
2023
- return proc_control (ps , p );
2036
+ ctrl .data = compat_ptr (udata );
2037
+ return do_proc_control (ps , & ctrl );
2024
2038
}
2025
2039
2026
2040
static int proc_bulk_compat (struct usb_dev_state * ps ,
2027
2041
struct usbdevfs_bulktransfer32 __user * p32 )
2028
2042
{
2029
- struct usbdevfs_bulktransfer __user * p ;
2030
- compat_uint_t n ;
2043
+ struct usbdevfs_bulktransfer bulk ;
2031
2044
compat_caddr_t addr ;
2032
2045
2033
- p = compat_alloc_user_space (sizeof (* p ));
2034
-
2035
- if (get_user (n , & p32 -> ep ) || put_user (n , & p -> ep ) ||
2036
- get_user (n , & p32 -> len ) || put_user (n , & p -> len ) ||
2037
- get_user (n , & p32 -> timeout ) || put_user (n , & p -> timeout ) ||
2038
- get_user (addr , & p32 -> data ) || put_user (compat_ptr (addr ), & p -> data ))
2046
+ if (get_user (bulk .ep , & p32 -> ep ) ||
2047
+ get_user (bulk .len , & p32 -> len ) ||
2048
+ get_user (bulk .timeout , & p32 -> timeout ) ||
2049
+ get_user (addr , & p32 -> data ))
2039
2050
return - EFAULT ;
2040
-
2041
- return proc_bulk (ps , p );
2051
+ bulk . data = compat_ptr ( addr );
2052
+ return do_proc_bulk (ps , & bulk );
2042
2053
}
2054
+
2043
2055
static int proc_disconnectsignal_compat (struct usb_dev_state * ps , void __user * arg )
2044
2056
{
2045
2057
struct usbdevfs_disconnectsignal32 ds ;
0 commit comments