Skip to content

Commit 51feb98

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: (48 commits) USB: otg: fix module reinsert issue USB: handle zero-length usbfs submissions correctly USB: EHCI: report actual_length for iso transfers USB: option: remove unnecessary and erroneous code USB: cypress_m8: remove invalid Clear-Halt USB: musb_host: undo incorrect change in musb_advance_schedule() USB: fix LANGID=0 regression USB: serial: sierra driver id_table additions USB serial: Add ID for Turtelizer, an FT2232L-based JTAG/RS-232 adapter. USB: fix race leading to a write after kfree in usbfs USB: Sierra: fix oops upon device close USB: option.c: add A-Link 3GU device id USB: Serial: Add support for Arkham Technology adapters USB: Fix option_ms regression in 2.6.31-rc2 USB: gadget audio: select SND_PCM USB: ftdi: support NDI devices Revert USB: usbfs: deprecate and hide option for !embedded USB: usb.h: fix kernel-doc notation USB: RNDIS gadget, fix issues talking from PXA USB: serial: FTDI with product code FB80 and vendor id 0403 ...
2 parents 8f8f013 + dc7520c commit 51feb98

48 files changed

Lines changed: 578 additions & 2383 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎drivers/usb/class/cdc-acm.c‎

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ static void acm_rx_tasklet(unsigned long _acm)
387387
struct acm_ru *rcv;
388388
unsigned long flags;
389389
unsigned char throttled;
390+
struct usb_host_endpoint *ep;
390391

391392
dbg("Entering acm_rx_tasklet");
392393

@@ -462,11 +463,20 @@ static void acm_rx_tasklet(unsigned long _acm)
462463

463464
rcv->buffer = buf;
464465

465-
usb_fill_bulk_urb(rcv->urb, acm->dev,
466-
acm->rx_endpoint,
467-
buf->base,
468-
acm->readsize,
469-
acm_read_bulk, rcv);
466+
ep = (usb_pipein(acm->rx_endpoint) ? acm->dev->ep_in : acm->dev->ep_out)
467+
[usb_pipeendpoint(acm->rx_endpoint)];
468+
if (usb_endpoint_xfer_int(&ep->desc))
469+
usb_fill_int_urb(rcv->urb, acm->dev,
470+
acm->rx_endpoint,
471+
buf->base,
472+
acm->readsize,
473+
acm_read_bulk, rcv, ep->desc.bInterval);
474+
else
475+
usb_fill_bulk_urb(rcv->urb, acm->dev,
476+
acm->rx_endpoint,
477+
buf->base,
478+
acm->readsize,
479+
acm_read_bulk, rcv);
470480
rcv->urb->transfer_dma = buf->dma;
471481
rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
472482

@@ -1227,9 +1237,14 @@ static int acm_probe(struct usb_interface *intf,
12271237
goto alloc_fail7;
12281238
}
12291239

1230-
usb_fill_bulk_urb(snd->urb, usb_dev,
1231-
usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress),
1232-
NULL, acm->writesize, acm_write_bulk, snd);
1240+
if (usb_endpoint_xfer_int(epwrite))
1241+
usb_fill_int_urb(snd->urb, usb_dev,
1242+
usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress),
1243+
NULL, acm->writesize, acm_write_bulk, snd, epwrite->bInterval);
1244+
else
1245+
usb_fill_bulk_urb(snd->urb, usb_dev,
1246+
usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress),
1247+
NULL, acm->writesize, acm_write_bulk, snd);
12331248
snd->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
12341249
snd->instance = acm;
12351250
}

‎drivers/usb/class/usbtmc.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ static int get_capabilities(struct usbtmc_device_data *data)
751751
{
752752
struct device *dev = &data->usb_dev->dev;
753753
char *buffer;
754-
int rv;
754+
int rv = 0;
755755

756756
buffer = kmalloc(0x18, GFP_KERNEL);
757757
if (!buffer)
@@ -763,7 +763,7 @@ static int get_capabilities(struct usbtmc_device_data *data)
763763
0, 0, buffer, 0x18, USBTMC_TIMEOUT);
764764
if (rv < 0) {
765765
dev_err(dev, "usb_control_msg returned %d\n", rv);
766-
return rv;
766+
goto err_out;
767767
}
768768

769769
dev_dbg(dev, "GET_CAPABILITIES returned %x\n", buffer[0]);
@@ -773,16 +773,18 @@ static int get_capabilities(struct usbtmc_device_data *data)
773773
dev_dbg(dev, "USB488 device capabilities are %x\n", buffer[15]);
774774
if (buffer[0] != USBTMC_STATUS_SUCCESS) {
775775
dev_err(dev, "GET_CAPABILITIES returned %x\n", buffer[0]);
776-
return -EPERM;
776+
rv = -EPERM;
777+
goto err_out;
777778
}
778779

779780
data->capabilities.interface_capabilities = buffer[4];
780781
data->capabilities.device_capabilities = buffer[5];
781782
data->capabilities.usb488_interface_capabilities = buffer[14];
782783
data->capabilities.usb488_device_capabilities = buffer[15];
783784

785+
err_out:
784786
kfree(buffer);
785-
return 0;
787+
return rv;
786788
}
787789

788790
#define capability_attribute(name) \

‎drivers/usb/core/Kconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ comment "Miscellaneous USB options"
2828
depends on USB
2929

3030
config USB_DEVICEFS
31-
bool "USB device filesystem (DEPRECATED)" if EMBEDDED
31+
bool "USB device filesystem (DEPRECATED)"
3232
depends on USB
3333
---help---
3434
If you say Y here (and to "/proc file system support" in the "File

‎drivers/usb/core/devices.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,19 @@ static const struct class_info clas_info[] =
136136
{USB_CLASS_AUDIO, "audio"},
137137
{USB_CLASS_COMM, "comm."},
138138
{USB_CLASS_HID, "HID"},
139-
{USB_CLASS_HUB, "hub"},
140139
{USB_CLASS_PHYSICAL, "PID"},
140+
{USB_CLASS_STILL_IMAGE, "still"},
141141
{USB_CLASS_PRINTER, "print"},
142142
{USB_CLASS_MASS_STORAGE, "stor."},
143+
{USB_CLASS_HUB, "hub"},
143144
{USB_CLASS_CDC_DATA, "data"},
144-
{USB_CLASS_APP_SPEC, "app."},
145-
{USB_CLASS_VENDOR_SPEC, "vend."},
146-
{USB_CLASS_STILL_IMAGE, "still"},
147145
{USB_CLASS_CSCID, "scard"},
148146
{USB_CLASS_CONTENT_SEC, "c-sec"},
149147
{USB_CLASS_VIDEO, "video"},
148+
{USB_CLASS_WIRELESS_CONTROLLER, "wlcon"},
149+
{USB_CLASS_MISC, "misc"},
150+
{USB_CLASS_APP_SPEC, "app."},
151+
{USB_CLASS_VENDOR_SPEC, "vend."},
150152
{-1, "unk."} /* leave as last */
151153
};
152154

‎drivers/usb/core/devio.c‎

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -325,21 +325,34 @@ static void async_completed(struct urb *urb)
325325
struct async *as = urb->context;
326326
struct dev_state *ps = as->ps;
327327
struct siginfo sinfo;
328+
struct pid *pid = NULL;
329+
uid_t uid = 0;
330+
uid_t euid = 0;
331+
u32 secid = 0;
332+
int signr;
328333

329334
spin_lock(&ps->lock);
330335
list_move_tail(&as->asynclist, &ps->async_completed);
331-
spin_unlock(&ps->lock);
332336
as->status = urb->status;
333-
if (as->signr) {
337+
signr = as->signr;
338+
if (signr) {
334339
sinfo.si_signo = as->signr;
335340
sinfo.si_errno = as->status;
336341
sinfo.si_code = SI_ASYNCIO;
337342
sinfo.si_addr = as->userurb;
338-
kill_pid_info_as_uid(as->signr, &sinfo, as->pid, as->uid,
339-
as->euid, as->secid);
343+
pid = as->pid;
344+
uid = as->uid;
345+
euid = as->euid;
346+
secid = as->secid;
340347
}
341348
snoop(&urb->dev->dev, "urb complete\n");
342349
snoop_urb(urb, as->userurb);
350+
spin_unlock(&ps->lock);
351+
352+
if (signr)
353+
kill_pid_info_as_uid(sinfo.si_signo, &sinfo, pid, uid,
354+
euid, secid);
355+
343356
wake_up(&ps->wait);
344357
}
345358

@@ -982,7 +995,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
982995
USBDEVFS_URB_ZERO_PACKET |
983996
USBDEVFS_URB_NO_INTERRUPT))
984997
return -EINVAL;
985-
if (!uurb->buffer)
998+
if (uurb->buffer_length > 0 && !uurb->buffer)
986999
return -EINVAL;
9871000
if (!(uurb->type == USBDEVFS_URB_TYPE_CONTROL &&
9881001
(uurb->endpoint & ~USB_ENDPOINT_DIR_MASK) == 0)) {
@@ -1038,11 +1051,6 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
10381051
is_in = 0;
10391052
uurb->endpoint &= ~USB_DIR_IN;
10401053
}
1041-
if (!access_ok(is_in ? VERIFY_WRITE : VERIFY_READ,
1042-
uurb->buffer, uurb->buffer_length)) {
1043-
kfree(dr);
1044-
return -EFAULT;
1045-
}
10461054
snoop(&ps->dev->dev, "control urb: bRequest=%02x "
10471055
"bRrequestType=%02x wValue=%04x "
10481056
"wIndex=%04x wLength=%04x\n",
@@ -1062,9 +1070,6 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
10621070
uurb->number_of_packets = 0;
10631071
if (uurb->buffer_length > MAX_USBFS_BUFFER_SIZE)
10641072
return -EINVAL;
1065-
if (!access_ok(is_in ? VERIFY_WRITE : VERIFY_READ,
1066-
uurb->buffer, uurb->buffer_length))
1067-
return -EFAULT;
10681073
snoop(&ps->dev->dev, "bulk urb\n");
10691074
break;
10701075

@@ -1106,28 +1111,35 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
11061111
return -EINVAL;
11071112
if (uurb->buffer_length > MAX_USBFS_BUFFER_SIZE)
11081113
return -EINVAL;
1109-
if (!access_ok(is_in ? VERIFY_WRITE : VERIFY_READ,
1110-
uurb->buffer, uurb->buffer_length))
1111-
return -EFAULT;
11121114
snoop(&ps->dev->dev, "interrupt urb\n");
11131115
break;
11141116

11151117
default:
11161118
return -EINVAL;
11171119
}
1118-
as = alloc_async(uurb->number_of_packets);
1119-
if (!as) {
1120+
if (uurb->buffer_length > 0 &&
1121+
!access_ok(is_in ? VERIFY_WRITE : VERIFY_READ,
1122+
uurb->buffer, uurb->buffer_length)) {
11201123
kfree(isopkt);
11211124
kfree(dr);
1122-
return -ENOMEM;
1125+
return -EFAULT;
11231126
}
1124-
as->urb->transfer_buffer = kmalloc(uurb->buffer_length, GFP_KERNEL);
1125-
if (!as->urb->transfer_buffer) {
1127+
as = alloc_async(uurb->number_of_packets);
1128+
if (!as) {
11261129
kfree(isopkt);
11271130
kfree(dr);
1128-
free_async(as);
11291131
return -ENOMEM;
11301132
}
1133+
if (uurb->buffer_length > 0) {
1134+
as->urb->transfer_buffer = kmalloc(uurb->buffer_length,
1135+
GFP_KERNEL);
1136+
if (!as->urb->transfer_buffer) {
1137+
kfree(isopkt);
1138+
kfree(dr);
1139+
free_async(as);
1140+
return -ENOMEM;
1141+
}
1142+
}
11311143
as->urb->dev = ps->dev;
11321144
as->urb->pipe = (uurb->type << 30) |
11331145
__create_pipe(ps->dev, uurb->endpoint & 0xf) |
@@ -1169,7 +1181,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
11691181
kfree(isopkt);
11701182
as->ps = ps;
11711183
as->userurb = arg;
1172-
if (uurb->endpoint & USB_DIR_IN)
1184+
if (is_in && uurb->buffer_length > 0)
11731185
as->userbuffer = uurb->buffer;
11741186
else
11751187
as->userbuffer = NULL;
@@ -1179,9 +1191,9 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
11791191
as->uid = cred->uid;
11801192
as->euid = cred->euid;
11811193
security_task_getsecid(current, &as->secid);
1182-
if (!is_in) {
1194+
if (!is_in && uurb->buffer_length > 0) {
11831195
if (copy_from_user(as->urb->transfer_buffer, uurb->buffer,
1184-
as->urb->transfer_buffer_length)) {
1196+
uurb->buffer_length)) {
11851197
free_async(as);
11861198
return -EFAULT;
11871199
}
@@ -1231,22 +1243,22 @@ static int processcompl(struct async *as, void __user * __user *arg)
12311243
if (as->userbuffer)
12321244
if (copy_to_user(as->userbuffer, urb->transfer_buffer,
12331245
urb->transfer_buffer_length))
1234-
return -EFAULT;
1246+
goto err_out;
12351247
if (put_user(as->status, &userurb->status))
1236-
return -EFAULT;
1248+
goto err_out;
12371249
if (put_user(urb->actual_length, &userurb->actual_length))
1238-
return -EFAULT;
1250+
goto err_out;
12391251
if (put_user(urb->error_count, &userurb->error_count))
1240-
return -EFAULT;
1252+
goto err_out;
12411253

12421254
if (usb_endpoint_xfer_isoc(&urb->ep->desc)) {
12431255
for (i = 0; i < urb->number_of_packets; i++) {
12441256
if (put_user(urb->iso_frame_desc[i].actual_length,
12451257
&userurb->iso_frame_desc[i].actual_length))
1246-
return -EFAULT;
1258+
goto err_out;
12471259
if (put_user(urb->iso_frame_desc[i].status,
12481260
&userurb->iso_frame_desc[i].status))
1249-
return -EFAULT;
1261+
goto err_out;
12501262
}
12511263
}
12521264

@@ -1255,6 +1267,10 @@ static int processcompl(struct async *as, void __user * __user *arg)
12551267
if (put_user(addr, (void __user * __user *)arg))
12561268
return -EFAULT;
12571269
return 0;
1270+
1271+
err_out:
1272+
free_async(as);
1273+
return -EFAULT;
12581274
}
12591275

12601276
static struct async *reap_as(struct dev_state *ps)

‎drivers/usb/core/hcd.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ struct hc_driver {
227227
/* has a port been handed over to a companion? */
228228
int (*port_handed_over)(struct usb_hcd *, int);
229229

230+
/* CLEAR_TT_BUFFER completion callback */
231+
void (*clear_tt_buffer_complete)(struct usb_hcd *,
232+
struct usb_host_endpoint *);
233+
230234
/* xHCI specific functions */
231235
/* Called by usb_alloc_dev to alloc HC device structures */
232236
int (*alloc_dev)(struct usb_hcd *, struct usb_device *);

0 commit comments

Comments
 (0)