1
linux/drivers/usb/serial
Alan Stern 2d93148ab6 USB: serial: fix lifetime and locking problems
This patch (as1229) fixes a few lifetime and locking problems in the
usb-serial driver.  The main symptom is that an invalid kevent is
created when the serial device is unplugged while a connection is
active.

	Ports should be unregistered when device is disconnected,
	not when the parent usb_serial structure is deallocated.

	Each open file should hold a reference to the corresponding
	port structure, and the reference should be released when
	the file is closed.

	serial->disc_mutex should be acquired in serial_open(), to
	resolve the classic race between open and disconnect.

	serial_close() doesn't need to hold both serial->disc_mutex
	and port->mutex at the same time.

	Release the subdriver's module reference only after releasing
	all the other references, in case one of the release routines
	needs to invoke some code in the subdriver module.

	Replace a call to flush_scheduled_work() (which is prone to
	deadlocks) with cancel_work_sync().  Also, add a call to
	cancel_work_sync() in the disconnect routine.

	Reduce the scope of serial->disc_mutex in serial_disconnect().
	The only place it really needs to protect is where the
	"disconnected" flag is set.

This fixes the bug reported in

	http://bugs.freedesktop.org/show_bug.cgi?id=20703

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: Dan Williams <dcbw@redhat.com>
Tested-by: Ming Lei <tom.leiming@gmail.com>
Reviewed-by: Oliver Neukum <oliver@neukum.org>
Acked-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-04-23 14:15:26 -07:00
..
aircable.c USB: usb-serial: fix the aircable_init failure path 2009-02-09 11:19:48 -08:00
ark3116.c
belkin_sa.c USB: remove use of err() in drivers/usb/serial 2008-10-17 14:41:10 -07:00
belkin_sa.h
bus.c
ch341.c USB: usb-serial ch341: support for DTR/RTS/CTS 2009-04-17 10:50:26 -07:00
ChangeLog.history trivial: Fix misspelling of firmware 2009-03-30 15:21:59 +02:00
console.c Add device function for USB serial console 2009-01-02 10:19:38 -08:00
cp210x.c USB: Fix cp2101 USB serial device driver termios functions for console use 2009-03-24 16:20:45 -07:00
cyberjack.c USB: remove use of err() in drivers/usb/serial 2008-10-17 14:41:10 -07:00
cypress_m8.c USB: remove use of err() in drivers/usb/serial 2008-10-17 14:41:10 -07:00
cypress_m8.h
digi_acceleport.c USB: serial: fix up urb->status usage 2009-01-07 10:00:06 -08:00
empeg.c USB: remove use of err() in drivers/usb/serial 2008-10-17 14:41:10 -07:00
ezusb_convert.pl
ezusb.c USB: remove use of err() in drivers/usb/serial 2008-10-17 14:41:10 -07:00
ftdi_sio.c USB: ftdi_sio: add vendor/project id for JETI specbos 1201 spectrometer 2009-04-17 10:50:24 -07:00
ftdi_sio.h USB: ftdi_sio: add vendor/project id for JETI specbos 1201 spectrometer 2009-04-17 10:50:24 -07:00
funsoft.c
garmin_gps.c USB: serial: fix up urb->status usage 2009-01-07 10:00:06 -08:00
generic.c USB: serial: export symbol of usb_serial_generic_resume 2009-03-24 16:20:29 -07:00
hp4x.c USB: remove info() macro from usb/serial drivers 2008-10-17 14:41:09 -07:00
io_16654.h
io_edgeport.c USB: remove use of err() in drivers/usb/serial 2008-10-17 14:41:10 -07:00
io_edgeport.h
io_ionsp.h
io_tables.h
io_ti.c USB: remove info() macro from usb/serial drivers 2008-10-17 14:41:09 -07:00
io_ti.h
io_usbvend.h
ipaq.c USB: ipaq: handle 4 endpoint devices 2009-03-24 16:20:45 -07:00
ipaq.h
ipw.c USB: serial: ipw.c: mark {__init|__exit} for usb_ipw_{init|exit} 2009-01-07 09:59:54 -08:00
ir-usb.c tty: trivial - fix up email addresses in tty related stuff 2008-11-11 09:30:10 -08:00
iuu_phoenix.c USB: serial: fix up urb->status usage 2009-01-07 10:00:06 -08:00
iuu_phoenix.h
Kconfig trivial: fix typos/grammar errors in Kconfig texts 2009-03-30 15:22:01 +02:00
keyspan_pda.c USB: remove use of err() in drivers/usb/serial 2008-10-17 14:41:10 -07:00
keyspan_usa26msg.h
keyspan_usa28msg.h
keyspan_usa49msg.h
keyspan_usa67msg.h
keyspan_usa90msg.h
keyspan.c USB: drivers: use USB API functions rather than constants 2009-03-24 16:20:28 -07:00
keyspan.h
kl5kusb105.c tty: Drop the lock_kernel in the private ioctl hook 2009-01-02 10:19:42 -08:00
kl5kusb105.h
kobil_sct.c USB: remove info() macro from usb/serial drivers 2008-10-17 14:41:09 -07:00
kobil_sct.h
Makefile USB: serial: rename cp2101 driver to cp210x 2009-03-24 16:20:44 -07:00
Makefile-keyspan_pda_fw
mct_u232.c tty: Drop the lock_kernel in the private ioctl hook 2009-01-02 10:19:42 -08:00
mct_u232.h
mos7720.c USB: remove use of err() in drivers/usb/serial 2008-10-17 14:41:10 -07:00
mos7840.c USB: serial: fix up urb->status usage 2009-01-07 10:00:06 -08:00
moto_modem.c USB device codes for Motorola phone. 2009-04-17 10:50:26 -07:00
navman.c tty: usb-serial krefs 2008-10-13 09:51:41 -07:00
omninet.c USB: remove use of err() in drivers/usb/serial 2008-10-17 14:41:10 -07:00
opticon.c USB: serial: opticon: add serial line ioctls 2009-03-24 16:20:30 -07:00
option.c USB: option: Add ids for D-Link DWM-652 3.5G modem 2009-04-17 10:50:24 -07:00
oti6858.c tty: usb-serial krefs 2008-10-13 09:51:41 -07:00
oti6858.h
pl2303.c tty: pl2303 needs identifiers for Siemens S81 as well as EF81 2009-04-06 14:36:41 -07:00
pl2303.h tty: pl2303 needs identifiers for Siemens S81 as well as EF81 2009-04-06 14:36:41 -07:00
qcserial.c USB: qcserial: Add extra device IDs 2009-04-17 10:50:24 -07:00
safe_serial.c USB: remove use of err() in drivers/usb/serial 2008-10-17 14:41:10 -07:00
siemens_mpi.c USB: add siemens_mpi usb-serial "stub" driver 2009-01-07 10:00:13 -08:00
sierra.c sierra: Fix formatting 2009-01-02 10:19:36 -08:00
spcp8x5.c USB: serial: fix up urb->status usage 2009-01-07 10:00:06 -08:00
symbolserial.c symbol: Remove various bits of left over junk 2009-04-06 14:36:42 -07:00
ti_usb_3410_5052.c tty: Fix leak in ti-usb 2009-04-14 08:48:50 -07:00
ti_usb_3410_5052.h USB: two more usb ids for ti_usb_3410_5052 2009-02-09 11:19:48 -08:00
usb_debug.c USB: serial: usb_debug: Make static 2009-01-07 10:00:03 -08:00
usb-serial.c USB: serial: fix lifetime and locking problems 2009-04-23 14:15:26 -07:00
visor.c USB: remove use of err() in drivers/usb/serial 2008-10-17 14:41:10 -07:00
visor.h
whiteheat.c USB: remove use of err() in drivers/usb/serial 2008-10-17 14:41:10 -07:00
whiteheat.h