linux/drivers/usb/serial
Aristeu Rozanski 9a6b1efa6f USB: usb_serial: clean tty reference in the last close
When a usb serial adapter is used as console, the usb serial console
driver bumps the open_count on the port struct used but doesn't attach
a real tty to it (only a fake one temporaly). If this port is opened later
using the regular character device interface, the open method won't
initialize the port, which is the expected, and will receive a brand new
tty struct created by tty layer, which will be stored in port->tty.

When the last close is issued, open_count won't be 0 because of the
console usage and the port->tty will still contain the old tty value. This
is the last ttyUSB<n> close so the allocated tty will be freed by the
tty layer. The usb_serial and usb_serial_port are still in use by the
console, so port_free() won't be called (serial_close() ->
usb_serial_put() -> destroy_serial() -> port_free()), so the scheduled
work (port->work, usb_serial_port_work()) will still run. And
usb_serial_port_work() does:
(...)
        tty = port->tty;
        if (!tty)
                return;

        tty_wakeup(tty);
which causes (manually copied):

Faulting instruction address: 0x6b6b6b68
Oops: Kernel access of bad area, sig: 11 [#1]
PREEMPT PowerMac
Modules linked in: binfmt_misc ipv6 nfs lockd nfs_acl sunrpc dm_snapshot dm_mirror dm_mod hfsplus uinput ams input_polldev genrtc cpufreq_powersave i2c_powermac therm_adt746x snd_aoa_codec_tas snd_aoa_fabric_layout snd_aoa joydev snd_aoa_i2sbus snd_pcm_oss snd_mixer_oss snd_pcm snd_timer snd_page_alloc pmac_zilog serial_core evdev ide_cd cdrom snd appletouch soundcore snd_aoa_soundbus bcm43xx firmware_class usbhid ieee80211softmac ff_memless firewire_ohci firewire_core ieee80211 ieee80211_crypt crc_itu_t sungem sungem_phy uninorth_agp agpart ssb
NIP: 6b6b6b68 LR: c01b2108 CTR: 6b6b6b6b
REGS: c106de80 TRAP: 0400   Not tainted  (2.6.24-rc2)
MSR: 40009032 <EE,ME,IR,DR>  CR: 82004024  XER: 00000000
TASK = c106b4c0[5] 'events/0' THREAD: c106c000
GPR00: 6b6b6b6b c106df30 c106b4c0 c2d613a0 00009032 00000001 00001a00 00000001
GPR08: 00000008 00000000 00000000 c106c000 42004028 00000000 016ffbe0 0171a724
GPR16: 016ffcf4 00240e24 00240e70 016fee68 016ff9a4 c03046c4 c0327f50 c03046fc
GPR24: c106b6b9 c106b4c0 c101d610 c106c000 c02160fc c1eac1dc c2d613ac c2d613a0
NIP [6b6b6b68] 0x6b6b6b68
LR [c01b2108] tty_wakeup+0x6c/0x9c
Call Trace:
[c106df30] [c01b20e8] tty_wakeup+0x4c/0x9c (unreliable)
[c106df40] [c0216138] usb_serial_port_work+0x3c/0x78
[c106df50] [c00432e8] run_workqueue+0xc4/0x15c
[c106df90] [c0043798] worker_thread+0xa0/0x124
[c106dfd0] [c0048224] kthread+0x48/0x84
[c106dff0] [c00129bc] kernel_thread+0x44/0x60
Instruction dump:
XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
Slab corruption: size-2048 start=c2d613a0, len=2048
Redzone: 0x9f911029d74e35b/0x9f911029d74e35b.
Last user: [<c01b16d8>](release_one_tty+0xbc/0xf4)
050: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
Prev obj: start=c2d60b88, len=2048
Redzone: 0x9f911029d74e35b/0x9f911029d74e35b.
Last user: [<c00f30ec>](show_stat+0x410/0x428)
000: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
010: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b

This patch avoids this, clearing port->tty considering if the port is
used as serial console or not

Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-02-01 14:34:50 -08:00
..
aircable.c USB: serial: aircable: clean up urb->status usage 2007-07-12 16:34:31 -07:00
airprime.c USB: fix support for Dell Wireless Broadband (aka WWAN) 2007-08-22 14:27:44 -07:00
ark3116.c USB: ark3116: update termios handling 2007-10-25 12:18:40 -07:00
belkin_sa.c USB: belkin_sa: avoid divide by zero error 2007-08-22 14:27:46 -07:00
belkin_sa.h
bus.c usb-serial: show port number in sysfs 2007-10-12 14:55:20 -07:00
ch341.c USB: ch341: fix termios handling 2007-10-25 12:18:40 -07:00
ChangeLog.history Convert files to UTF-8 and some cleanups 2007-10-19 23:21:04 +02:00
console.c USB: usb_serial: clean tty reference in the last close 2008-02-01 14:34:50 -08:00
cp2101.c USB: CP2101 New Device IDs 2008-02-01 14:34:43 -08:00
cyberjack.c USB: serial: cyberjack: clean up urb->status usage 2007-07-12 16:34:32 -07:00
cypress_m8.c USB: serial: cypress_m8: clean up urb->status usage 2007-07-12 16:34:32 -07:00
cypress_m8.h
digi_acceleport.c USB: digi_acceleport: fix termios and also readability a bit 2007-10-25 12:18:41 -07:00
empeg.c USB: empeg: clean up and handle speeds 2007-10-25 12:18:41 -07:00
ezusb_convert.pl
ezusb.c
ftdi_sio.c USB: ftdi driver - add support for optical probe device 2008-02-01 14:34:45 -08:00
ftdi_sio.h USB: ftdi driver - add support for optical probe device 2008-02-01 14:34:45 -08:00
funsoft.c USB: funsoft: Fix termios 2007-10-12 14:55:32 -07:00
garmin_gps.c USB: serial: garmin_gps: fixes package loss if used from gpsbabel 2007-08-22 14:27:44 -07:00
generic.c usbserial: fix inconsistent lock state 2007-11-28 13:58:34 -08:00
hp4x.c
io_16654.h
io_edgeport.c USB: io_edgeport: cleanups, and tty speed reporting 2007-10-25 12:18:43 -07:00
io_edgeport.h
io_fw_boot2.h
io_fw_boot.h
io_fw_down2.h
io_fw_down3.h USB: io_ti: Digi EdgePort update for new devices 2007-07-12 16:29:48 -07:00
io_fw_down.h
io_ionsp.h
io_tables.h
io_ti.c USB: Remove pointless conditional in drivers/usb/serial/io_ti.c::edge_shutdown() 2007-07-19 17:46:05 -07:00
io_ti.h
io_usbvend.h USB: io_ti: Digi EdgePort update for new devices 2007-07-12 16:29:48 -07:00
ipaq.c Convert files to UTF-8 and some cleanups 2007-10-19 23:21:04 +02:00
ipaq.h
ipw.c Add missing newlines to some uses of dev_<level> messages 2007-10-18 14:37:28 -07:00
ir-usb.c USB: ir_usb: termios handling 2007-10-25 12:18:41 -07:00
iuu_phoenix.c USB: add iuu_phoenix driver 2008-02-01 14:34:47 -08:00
iuu_phoenix.h USB: add iuu_phoenix driver 2008-02-01 14:34:47 -08:00
Kconfig USB: add iuu_phoenix driver 2008-02-01 14:34:47 -08:00
keyspan_mpr_fw.h
keyspan_pda_fw.h
keyspan_pda.c USB: serial: keyspan_pda: clean up urb->status usage 2007-07-12 16:34:35 -07:00
keyspan_pda.S
keyspan_usa18x_fw.h
keyspan_usa19_fw.h
keyspan_usa19qi_fw.h
keyspan_usa19qw_fw.h
keyspan_usa19w_fw.h
keyspan_usa26msg.h
keyspan_usa28_fw.h
keyspan_usa28msg.h
keyspan_usa28x_fw.h
keyspan_usa28xa_fw.h
keyspan_usa28xb_fw.h
keyspan_usa49msg.h
keyspan_usa49w_fw.h
keyspan_usa49wlc_fw.h
keyspan_usa67msg.h USB Serial Keyspan: add support for USA-49WG & USA-28XG 2007-07-12 16:29:45 -07:00
keyspan_usa90msg.h
keyspan.c USB: keyspan: Fix oops 2008-02-01 14:34:42 -08:00
keyspan.h USB Serial Keyspan: add support for USA-49WG & USA-28XG 2007-07-12 16:29:45 -07:00
kl5kusb105.c USB: kl5kusb105: witch to new speed API 2007-10-12 14:55:15 -07:00
kl5kusb105.h
kobil_sct.c USB: kobil_sct: termios encoding fixups 2007-10-25 12:18:41 -07:00
kobil_sct.h
Makefile USB: add iuu_phoenix driver 2008-02-01 14:34:47 -08:00
Makefile-keyspan_pda_fw
mct_u232.c USB: mct_u232-convert-to-proper-speed-handling-api-fix 2007-10-12 14:55:15 -07:00
mct_u232.h USB: mct_u232: Convert to proper speed handling API 2007-07-30 13:27:46 -07:00
mos7720.c Add missing newlines to some uses of dev_<level> messages 2007-10-18 14:37:28 -07:00
mos7840.c USB: free memory when writing fails in usb/serial/mos7840.c 2007-11-28 13:58:33 -08:00
navman.c USB: serial: navman: clean up urb->status usage 2007-07-12 16:34:35 -07:00
omninet.c USB: serial: omninet: clean up urb->status usage 2007-07-12 16:34:35 -07:00
option.c USB: Variant of the Dell Wireless 5520 driver 2008-02-01 14:34:46 -08:00
oti6858.c Add missing newlines to some uses of dev_<level> messages 2007-10-18 14:37:28 -07:00
oti6858.h USB: oti6858 usb-serial driver (in Nokia CA-42 cable) 2007-07-12 16:29:47 -07:00
pl2303.c USB: pl2303: add support for RATOC REX-USB60F 2008-02-01 14:34:45 -08:00
pl2303.h USB: pl2303: add support for RATOC REX-USB60F 2008-02-01 14:34:45 -08:00
safe_serial.c USB: Remove dead references to "SAFE_SERIAL" CONFIG variables. 2007-10-12 14:54:59 -07:00
sierra.c USB: sierra: add support for Onda H600/Zte MF330 datacard to USB Driver for Sierra Wireless 2008-02-01 14:34:45 -08:00
ti_fw_3410.h
ti_fw_5052.h
ti_usb_3410_5052.c USB: TI 3410/5052 USB Serial: convert td_open_close_lock to mutex 2008-02-01 14:34:48 -08:00
ti_usb_3410_5052.h
usb_debug.c
usb-serial.c USB: usb_serial: clean tty reference in the last close 2008-02-01 14:34:50 -08:00
visor.c USB: visor: termios bits 2007-10-12 14:55:32 -07:00
visor.h USB: visor add ACER S10 palm device id 2007-08-22 14:27:43 -07:00
whiteheat_fw.h
whiteheat.c USB: whiteheat: clean up can't happen checks and encode baud rate 2007-10-25 12:18:42 -07:00
whiteheat.h
xircom_pgs_fw.h
xircom_pgs.S