Bug 12137

Summary: cyclades multiport driver - module load error path does not free resources
Product: Drivers Reporter: Florian Lohoff (flo)
Component: OtherAssignee: drivers_other
Status: CLOSED CODE_FIX    
Severity: normal CC: alan
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.26 Subsystem:
Regression: No Bisected commit-id:
Attachments: fix

Description Florian Lohoff 2008-12-02 03:44:35 UTC
Latest working kernel version: 2.6.26
Earliest failing kernel version: 2.6.18 (first encountered the problem and reported)
Distribution: Debian
Hardware Environment: x86
Software Environment: 
Problem Description: The module load error path in cyclades driver is broken. In case the external serial breakout box is not connected the driver reports with 0 ports. After unloading the module its impossible to load the module again because some resources are still in use. Doing a cat on /proc/ioports crashes the machine.

Reported as Debian bug #429011 - http://bugs.debian.org/429011 against 2.6.18 and verified to still exist against 2.6.26 (linux-image-2.6.26-1-686 2.6.26-12~snapshot.12453)

Oops when catting /proc/ioports

[  202.976225] BUG: unable to handle kernel paging request at c8a06e6b
[  202.980065] IP: [<c01e1802>] strnlen+0x6/0x18
[  202.980065] *pde = 07419067 *pte = 00000000
[  202.980065] Oops: 0000 [#1] SMP
[  202.980065] Modules linked in: autofs4 ac battery ipv6 dm_snapshot dm_mirror dm_log dm_mod firmware_class snd_ens1371
+gameport snd_rawmidi snd_seq_device snd_ac97_codec ac97_bus rng_core parport_pc parport intel_agp button shpchp i2c_i801
+ snd_pcm snd_timer i2c_core snd soundcore snd_page_alloc agpgart evdev iTCO_wdt pci_hotplug floppy pcspkr joydev ext3 jb
+d mbcache ide_disk ata_generic libata scsi_mod dock uhci_hcd piix usbcore e100 mii ide_core thermal processor fan therma
+l_sys [last unloaded: cyclades]
[  202.980065]
[  202.980065] Pid: 2520, comm: cat Not tainted (2.6.26-1-686 #1)
[  202.980065] EIP: 0060:[<c01e1802>] EFLAGS: 00010297 CPU: 0
[  202.980065] EIP is at strnlen+0x6/0x18
[  202.980065] EAX: c8a06e6b EBX: c6509346 ECX: c8a06e6b EDX: fffffffe
[  202.980065] ESI: c8a06e6b EDI: ffffffff EBP: c650a000 ESP: c77f5da4
[  202.980065]  DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
[  202.980065] Process cat (pid: 2520, ti=c77f4000 task=c77eea20 task.ti=c77f4000)
[  202.980065] Stack: c01e0c60 c77f5f1c c6509346 c77f5f1c ffffffff c01e0f35 ffffffff ffffffff
[  202.980065]        00000000 00000cca c6509336 0000bc12 00000010 c650a000 00000000 ffffffff
[  202.980065]        c0311510 c1109420 00000086 000005fd 00000000 4250e0f7 0000002f 4250f6c7
[  202.980065] Call Trace:
[  202.980065]  [<c01e0c60>] string+0x27/0x6f
[  202.980065]  [<c01e0f35>] vsnprintf+0x28d/0x452
[  202.980065]  [<c0133b28>] hrtimer_forward+0xe4/0x100
[  202.980065]  [<c013604c>] getnstimeofday+0x37/0xbc
[  202.980065]  [<c0108066>] pit_next_event+0x25/0x30
[  202.980065]  [<c0138770>] clockevents_program_event+0xc4/0xd2
[  202.980065]  [<c0139472>] tick_dev_program_event+0x1e/0x82
[  202.980065]  [<c0139525>] tick_program_event+0x1f/0x23
[  202.980065]  [<c0134658>] hrtimer_interrupt+0x12d/0x155
[  202.980065]  [<c012956e>] run_timer_softirq+0x30/0x17c
[  202.980065]  [<c0153b87>] __rcu_process_callbacks+0x8e/0x154
[  202.980065]  [<c0126579>] __do_softirq+0x66/0xd3
[  202.980065]  [<c018a209>] seq_printf+0x2b/0x48
[  202.980065]  [<c0126de5>] r_show+0x5b/0x64
[  202.980065]  [<c018a7bb>] seq_read+0x196/0x26f
[  202.980065]  [<c018a625>] seq_read+0x0/0x26f
[  202.980065]  [<c01a1162>] proc_reg_read+0x58/0x6b
[  202.980065]  [<c01a110a>] proc_reg_read+0x0/0x6b
[  202.980065]  [<c0174992>] vfs_read+0x81/0x11e
[  202.980065]  [<c0174de3>] sys_read+0x3c/0x63
[  202.980065]  [<c01038ce>] syscall_call+0x7/0xb
[  202.980065]  =======================
[  202.980065] Code: c9 74 0c f2 ae 74 05 bf 01 00 00 00 4f 89 fa 5f 89 d0 c3 85 c9 57 89 c7 89 d0 74 05 f2 ae 75 01 4f 8
[  202.980065] EIP: [<c01e1802>] strnlen+0x6/0x18 SS:ESP 0068:c77f5da4
[  202.980065] ---[ end trace 3c1a37ae88182d0f ]---


Steps to reproduce:

Disconnect external serial breakout box (poweroff before)
modprobe cyclades
rmmod cyclades
modprobe cyclades (reports fail to load because of resource in use)
cat /proc/ioports (throws oops)

Last git commits against the error path on cyclades have been for 2.6.22.
Comment 1 Andrew Morton 2008-12-03 00:10:27 UTC
Created attachment 19121 [details]
fix

Does this fix?