The probe does not strictly require the USB_CDC_DMM_TYPE descriptor, which is a good thing as it makes the driver usable on non-conforming interfaces. A user could e.g. bind to it to a CDC ECM interface by using the new_id and bind sysfs files. But this would fail with a 0 buffer length due to the missing descriptor. Fix by defining a reasonable fallback size: The minimum device receive buffer size required by the CDC WMC standard, revision 1.1 Cc: stable@xxxxxxxxxxxxxxx # 2.6.32.y, 3.0.y, 3.2.y Signed-off-by: Bjørn Mork <bjorn@xxxxxxx> --- Just for the sake of it, I had to test this on a stock Debian Wheezy kernel (based on v3.1.x). Adding the Huawei modem: nemi:/tmp# echo "12d1 1506" > /sys/bus/usb/drivers/cdc_wdm/new_id Starts out OK, but lockups when reading from the device: Jan 19 19:52:41 nemi kernel: [ 645.879510] cdc_wdm 2-1:1.3: Ignoring extra header, type 15, length 13 Jan 19 19:52:41 nemi kernel: [ 645.879520] cdc_wdm 2-1:1.3: Ignoring extra header, type 6, length 5 Jan 19 19:52:41 nemi kernel: [ 645.879768] cdc_wdm 2-1:1.3: cdc-wdm-174: USB WDM device Jan 19 19:52:41 nemi kernel: [ 645.879800] cdc_wdm: probe of 2-1:1.4 failed with error -22 Jan 19 19:54:27 nemi kernel: [ 752.072013] BUG: soft lockup - CPU#0 stuck for 22s! [qmidevdebug.py:6156] Jan 19 19:54:27 nemi kernel: [ 752.072018] Modules linked in: {removed as git-send-email doesn't like kilobyte lines} Jan 19 19:54:27 nemi kernel: [ 752.072149] CPU 0 Jan 19 19:54:27 nemi kernel: [ 752.072150] Modules linked in: {removed as git-send-email doesn't like kilobyte lines} Jan 19 19:54:27 nemi kernel: [ 752.072255] Jan 19 19:54:27 nemi kernel: [ 752.072258] Pid: 6156, comm: qmidevdebug.py Tainted: G O 3.1.0-1-amd64 #1 LENOVO 2776LEG/2776LEG Jan 19 19:54:27 nemi kernel: [ 752.072264] RIP: 0010:[<ffffffff8132de3d>] [<ffffffff8132de3d>] _raw_spin_lock_irq+0x5/0x14 Jan 19 19:54:27 nemi kernel: [ 752.072273] RSP: 0018:ffff88023090de68 EFLAGS: 00000246 Jan 19 19:54:27 nemi kernel: [ 752.072276] RAX: ffff880231d2fe10 RBX: ffff8802315c9040 RCX: 000000010001b979 Jan 19 19:54:27 nemi kernel: [ 752.072279] RDX: 0000000000000000 RSI: ffff880231d2fe10 RDI: ffff880231d2fe10 Jan 19 19:54:27 nemi kernel: [ 752.072283] RBP: ffff88023090deb0 R08: ffff88023090c000 R09: 0000000000000000 Jan 19 19:54:27 nemi kernel: [ 752.072286] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000012f40 Jan 19 19:54:27 nemi kernel: [ 752.072289] R13: ffffffff8160d020 R14: ffffffff810387af R15: ffff88022f9b55d0 Jan 19 19:54:27 nemi kernel: [ 752.072293] FS: 00007fce32c8e700(0000) GS:ffff88023bc00000(0000) knlGS:0000000000000000 Jan 19 19:54:27 nemi kernel: [ 752.072296] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b Jan 19 19:54:27 nemi kernel: [ 752.072299] CR2: 0000000000412ccb CR3: 00000002250c5000 CR4: 00000000000006f0 Jan 19 19:54:27 nemi kernel: [ 752.072303] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 Jan 19 19:54:27 nemi kernel: [ 752.072306] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Jan 19 19:54:27 nemi kernel: [ 752.072310] Process qmidevdebug.py (pid: 6156, threadinfo ffff88023090c000, task ffff88022f9b55d0) Jan 19 19:54:27 nemi kernel: [ 752.072313] Stack: Jan 19 19:54:27 nemi kernel: [ 752.072315] ffff880231d2fe10 ffffffffa063478a 0000000100020000 ffff880231d2fe10 Jan 19 19:54:27 nemi kernel: [ 752.072321] ffff880231d2fe50 0000000000000100 ffff880231d2fe70 0000000000b6dc94 Jan 19 19:54:27 nemi kernel: [ 752.072327] 0000000000000000 0000000000000000 ffff88022f9b55d0 ffffffff8105ec6b Jan 19 19:54:27 nemi kernel: [ 752.072333] Call Trace: Jan 19 19:54:27 nemi kernel: [ 752.072339] [<ffffffffa063478a>] ? wdm_read+0x156/0x24c [cdc_wdm] Jan 19 19:54:27 nemi kernel: [ 752.072345] [<ffffffff8105ec6b>] ? add_wait_queue+0x3c/0x3c Jan 19 19:54:27 nemi kernel: [ 752.072351] [<ffffffff810f4178>] ? vfs_read+0x9f/0xe6 Jan 19 19:54:27 nemi kernel: [ 752.072355] [<ffffffff810f4204>] ? sys_read+0x45/0x6b Jan 19 19:54:27 nemi kernel: [ 752.072361] [<ffffffff81332e12>] ? system_call_fastpath+0x16/0x1b Jan 19 19:54:27 nemi kernel: [ 752.072363] Code: ff 53 48 89 fb e8 48 23 d4 ff ba 00 00 01 00 f0 0f c1 13 0f b7 ca c1 ea 10 39 d1 74 07 f3 90 0f b7 0b eb f5 5b c3 51 48 89 3c 24 <e8> 1a 23 d4 ff 48 8b 3c 24 5e e9 49 23 d4 ff 48 89 f8 48 89 f7 Jan 19 19:54:27 nemi kernel: [ 752.072404] Call Trace: Jan 19 19:54:27 nemi kernel: [ 752.072409] [<ffffffffa063478a>] ? wdm_read+0x156/0x24c [cdc_wdm] Jan 19 19:54:27 nemi kernel: [ 752.072413] [<ffffffff8105ec6b>] ? add_wait_queue+0x3c/0x3c Jan 19 19:54:27 nemi kernel: [ 752.072417] [<ffffffff810f4178>] ? vfs_read+0x9f/0xe6 Jan 19 19:54:27 nemi kernel: [ 752.072422] [<ffffffff810f4204>] ? sys_read+0x45/0x6b Jan 19 19:54:27 nemi kernel: [ 752.072426] [<ffffffff81332e12>] ? system_call_fastpath+0x16/0x1b Not good. drivers/usb/class/cdc-wdm.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c index fe22d17..b4c42c1 100644 --- a/drivers/usb/class/cdc-wdm.c +++ b/drivers/usb/class/cdc-wdm.c @@ -57,6 +57,8 @@ MODULE_DEVICE_TABLE (usb, wdm_ids); #define WDM_MAX 16 +/* CDC-WMC r1.1 requires wMaxCommand to be "at least 256 decimal (0x100)" */ +#define WDM_DEFAULT_BUFSIZE 256 static DEFINE_MUTEX(wdm_mutex); @@ -608,7 +610,7 @@ static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id) struct usb_cdc_dmm_desc *dmhd; u8 *buffer = intf->altsetting->extra; int buflen = intf->altsetting->extralen; - u16 maxcom = 0; + u16 maxcom = WDM_DEFAULT_BUFSIZE; if (!buffer) goto out; -- 1.7.8.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html