]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit - drivers/tty/n_gsm.c
tty: n_gsm: Added refcount usage to gsm_mux and gsm_dlci structs
authorRuss Gorby <russ.gorby@intel.com>
Thu, 16 Jun 2011 21:20:13 +0000 (14:20 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 1 Jul 2011 22:34:50 +0000 (15:34 -0700)
commit6ab8fba7fcb012a42d686abd33555b2215071415
treee30be9d556f7179ad606cb473e9003c9dea7b4a2
parentbcd5abe28f40cc6a935d3339cde27976f6be3f1a
tty: n_gsm: Added refcount usage to gsm_mux and gsm_dlci structs

The gsm_mux is created/destroyed when ldisc is
opened/closed but clients of the MUX channel devices (gsmttyN)
may access this structure as long as the TTYs are open.
For the open, the ldisc open is guaranteed to preceed the TTY open,
but the close has no such guaranteed ordering. As a result,
the gsm_mux can be freed in the ldisc close before being accessed
by one of the TTY clients. This can happen if the ldisc is removed
while there are open, active MUX channels.
A similar situation exists for DLCI-0, it is basically a resource
shared by MUX and DLCI  , and should not be freed while they can
be accessed

To avoid this, gsm_mux and dlcis now have a reference counter
ldisc open takes a reference on the mux and all the dlcis
gsmtty_open takes a reference on the mux, dlci0 and its specific
dlci. Dropping the last reference initiates the actual free.

Signed-off-by: Russ Gorby <russ.gorby@intel.com>
Acked-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/tty/n_gsm.c