Re: sysfs_attr_ns: missing error handling & problem with usb/serial/io_ti

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 13/01/12 20:00, Greg KH wrote:
> On Fri, Jan 13, 2012 at 07:49:07PM +0100, Wolfgang Frisch wrote:
>> Hi,
>>
>> my USB device is causing a kernel oops upon disconnection.
>>
>> It's a "Inside Out Networks Watchport/H" sensor,
>> vendor: 0x1608, product: 0x305, Linux driver: io_ti.
>> The problem appeared after v3.1.
>>
>> A git bisect from v3.1 to v3.2 yielded this commit:
>> ---------------------------------------------------------------
>> 487505c257021fc06a7d05753cf27b011487f1dc is the first bad commit
>> commit 487505c257021fc06a7d05753cf27b011487f1dc
>> Author: Eric W. Biederman <ebiederm@xxxxxxxxxxxx>
>> Date:   Wed Oct 12 21:53:38 2011 +0000
>>
>>     sysfs: Implement support for tagged files in sysfs.
>> ---------------------------------------------------------------
>>
>> This commit introduces a new function sysfs_attr_ns()
>> It assumes that kobj->sd is a valid directory entry and dereferences it
>> unconditionally. This missing check causes a NULL pointer exception when
>> the io_ti device is disconnected. My attached patch fixes the symptom by
>> adding a check to sysfs_attr_ns().
>>
>> The driver works as expected with this patch. However it still leaves a
>> kernel warning message upon disconnection. Unfortunately my
>> understanding of sysfs and the io_ti driver is not good enough to
>> recognize any further, underlying problems.
> 
> Do you have network namespaces enabled?

Yes, CONFIG_NET_NS was set to "y".
Disabling it does not affect the driver's behavior.

> Eric, any thoughts about this?
> 
> thanks,
> 
> greg k-h
> 
>>
>> Best Regards,
>> Wolfgang Frisch
> 
>> Jan 13 16:44:12 pure-squeeze kernel: [   58.239165] usb 1-2: new full-speed USB device number 3 using ohci_hcd
>> Jan 13 16:44:12 pure-squeeze kernel: [   58.565958] usb 1-2: New USB device found, idVendor=1608, idProduct=0305
>> Jan 13 16:44:12 pure-squeeze kernel: [   58.565961] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
>> Jan 13 16:44:12 pure-squeeze kernel: [   58.565964] usb 1-2: Product: Watchport/H
>> Jan 13 16:44:12 pure-squeeze kernel: [   58.565966] usb 1-2: Manufacturer: Inside Out Networks
>> Jan 13 16:44:12 pure-squeeze kernel: [   58.565968] usb 1-2: SerialNumber: V51055643-0
>> Jan 13 16:44:12 pure-squeeze kernel: [   58.656163] usbcore: registered new interface driver usbserial
>> Jan 13 16:44:12 pure-squeeze kernel: [   58.656190] USB Serial support registered for generic
>> Jan 13 16:44:12 pure-squeeze kernel: [   58.656225] usbcore: registered new interface driver usbserial_generic
>> Jan 13 16:44:12 pure-squeeze kernel: [   58.656227] usbserial: USB Serial Driver core
>> Jan 13 16:44:12 pure-squeeze kernel: [   58.663856] USB Serial support registered for Edgeport TI 1 port adapter
>> Jan 13 16:44:12 pure-squeeze kernel: [   58.664358] USB Serial support registered for Edgeport TI 2 port adapter
>> Jan 13 16:44:12 pure-squeeze kernel: [   58.664689] io_ti 1-2:1.0: Edgeport TI 1 port adapter converter detected
>> Jan 13 16:44:12 pure-squeeze kernel: [   58.998697] usb 1-2: Edgeport TI 1 port adapter converter now attached to ttyUSB0
>> Jan 13 16:44:12 pure-squeeze kernel: [   58.998779] usbcore: registered new interface driver io_ti
>> Jan 13 16:44:12 pure-squeeze kernel: [   58.998781] io_ti: v0.7mode043006:Edgeport USB Serial Driver
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.953876] usb 1-2: USB disconnect, device number 3
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.954311] edgeport_ti_1 ttyUSB0: Edgeport TI 1 port adapter converter now disconnected from ttyUSB0
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077] PGD 0 
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077] CPU 0 
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077] Modules linked in: io_ti usbserial e1000
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077] 
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077] Pid: 266, comm: khubd Not tainted 3.2.0-vbox #42 innotek GmbH VirtualBox
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077] RIP: 0010:[<ffffffff8112b404>]  [<ffffffff8112b404>] sysfs_attr_ns+0x10/0x66
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077] RSP: 0018:ffff88007c89dba0  EFLAGS: 00010246
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077] RAX: 0000000000000000 RBX: ffff88007c89dbc8 RCX: ffff88007bc47fa0
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077] RDX: 0000000000000000 RSI: ffffffffa0032480 RDI: ffff88007c221a00
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077] RBP: ffff88007c89dbb0 R08: 0000000000000000 R09: 0000000000020001
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077] R10: 0000000000020001 R11: ffff88007bdc4bd0 R12: ffff88007c221a00
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077] R13: ffff88007c221800 R14: 0000000000000001 R15: 0000000000000000
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077] FS:  0000000000000000(0000) GS:ffff88007fc00000(0000) knlGS:0000000000000000
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077] CR2: 0000000000000079 CR3: 000000007c1e6000 CR4: 00000000000006f0
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077] Process khubd (pid: 266, threadinfo ffff88007c89c000, task ffff88007d3fb980)
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  0000000000020001 ffffffffa0032480 ffff88007c89dbe0 ffffffff8112b474
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  ffff88007ba26e00 ffff88007c2219f0 ffff88007bdeb9c0 0000000000000001
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  ffff88007c89dbf0 ffffffff812ba2a7 ffff88007c89dc10 ffffffffa002cdbc
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  [<ffffffff8112b474>] sysfs_remove_file+0x1a/0x37
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  [<ffffffff812ba2a7>] device_remove_file+0x12/0x14
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  [<ffffffffa002cdbc>] edge_disconnect+0x5c/0x6f [io_ti]
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  [<ffffffffa001f354>] usb_serial_disconnect+0x11e/0x144 [usbserial]
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  [<ffffffff8131ea17>] usb_unbind_interface+0x45/0xc3
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  [<ffffffff812bcd65>] __device_release_driver+0x67/0xb0
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  [<ffffffff812bcdcc>] device_release_driver+0x1e/0x2b
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  [<ffffffff812bc9c4>] bus_remove_device+0x81/0x91
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  [<ffffffff812ba82b>] device_del+0x127/0x179
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  [<ffffffff8131d8ba>] usb_disable_device+0xa8/0x1d8
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  [<ffffffff81317072>] usb_disconnect+0xa7/0x116
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  [<ffffffff81318491>] hub_thread+0x64c/0x1057
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  [<ffffffff8102b988>] ? dequeue_task_fair+0x11d/0x12a
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  [<ffffffff8104debd>] ? add_wait_queue+0x44/0x44
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  [<ffffffff81317e45>] ? usb_new_device+0x16e/0x16e
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  [<ffffffff8104d7fd>] kthread+0x7f/0x87
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  [<ffffffff8145ba34>] kernel_thread_helper+0x4/0x10
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  [<ffffffff8104d77e>] ? kthread_worker_fn+0x12f/0x12f
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  [<ffffffff8145ba30>] ? gs_change+0xb/0xb
>> Jan 13 16:44:14 pure-squeeze kernel: [   59.955077]  RSP <ffff88007c89dba0>
>> Jan 13 16:44:14 pure-squeeze kernel: [   60.019735] ---[ end trace bf7b4f5738921164 ]---
>> Jan 13 16:44:14 pure-squeeze kernel: [   60.020487] khubd used greatest stack depth: 4056 bytes left
>>
> 
>> diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
>> index 07c1b4e..876885e 100644
>> --- a/fs/sysfs/file.c
>> +++ b/fs/sysfs/file.c
>> @@ -496,6 +496,10 @@ int sysfs_attr_ns(struct kobject *kobj, const struct attribute *attr,
>>  	const void *ns = NULL;
>>  	int err;
>>  
>> +	err = -ENOENT;
>> +	if (!dir_sd)
>> +		goto out;
>> +
>>  	err = 0;
>>  	if (!sysfs_ns_type(dir_sd))
>>  		goto out;
> 

--
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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux