diff options
author | Jiri Slaby <jslaby@suse.cz> | 2012-11-15 03:49:53 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-11-15 20:20:57 -0500 |
commit | 9a8e62bc68832dc55a5e6868f812b65567fe66b5 (patch) | |
tree | d02424332c1274547295d87c30b16aec920b455e /drivers/tty/n_gsm.c | |
parent | e70c67713cdabf55e05db7f1c4fc38085da333a5 (diff) |
TTY: n_gsm, use kref from tty_port
After commit "TTY: move tty buffers to tty_port", the tty buffers are
not freed in some drivers. This is because tty_port_destructor is not
called whenever a tty_port is freed. This was an assumption I counted
with but was unfortunately untrue. So fix the drivers to fulfil this
assumption.
Here it is enough to switch to refcounting in tty_port.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/n_gsm.c')
-rw-r--r-- | drivers/tty/n_gsm.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 1e8e8ce55959..dcc0430a49c8 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c | |||
@@ -134,7 +134,6 @@ struct gsm_dlci { | |||
134 | #define DLCI_OPENING 1 /* Sending SABM not seen UA */ | 134 | #define DLCI_OPENING 1 /* Sending SABM not seen UA */ |
135 | #define DLCI_OPEN 2 /* SABM/UA complete */ | 135 | #define DLCI_OPEN 2 /* SABM/UA complete */ |
136 | #define DLCI_CLOSING 3 /* Sending DISC not seen UA/DM */ | 136 | #define DLCI_CLOSING 3 /* Sending DISC not seen UA/DM */ |
137 | struct kref ref; /* freed from port or mux close */ | ||
138 | struct mutex mutex; | 137 | struct mutex mutex; |
139 | 138 | ||
140 | /* Link layer */ | 139 | /* Link layer */ |
@@ -1635,7 +1634,6 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr) | |||
1635 | if (dlci == NULL) | 1634 | if (dlci == NULL) |
1636 | return NULL; | 1635 | return NULL; |
1637 | spin_lock_init(&dlci->lock); | 1636 | spin_lock_init(&dlci->lock); |
1638 | kref_init(&dlci->ref); | ||
1639 | mutex_init(&dlci->mutex); | 1637 | mutex_init(&dlci->mutex); |
1640 | dlci->fifo = &dlci->_fifo; | 1638 | dlci->fifo = &dlci->_fifo; |
1641 | if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) { | 1639 | if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) { |
@@ -1669,9 +1667,9 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr) | |||
1669 | * | 1667 | * |
1670 | * Can sleep. | 1668 | * Can sleep. |
1671 | */ | 1669 | */ |
1672 | static void gsm_dlci_free(struct kref *ref) | 1670 | static void gsm_dlci_free(struct tty_port *port) |
1673 | { | 1671 | { |
1674 | struct gsm_dlci *dlci = container_of(ref, struct gsm_dlci, ref); | 1672 | struct gsm_dlci *dlci = container_of(port, struct gsm_dlci, port); |
1675 | 1673 | ||
1676 | del_timer_sync(&dlci->t1); | 1674 | del_timer_sync(&dlci->t1); |
1677 | dlci->gsm->dlci[dlci->addr] = NULL; | 1675 | dlci->gsm->dlci[dlci->addr] = NULL; |
@@ -1683,12 +1681,12 @@ static void gsm_dlci_free(struct kref *ref) | |||
1683 | 1681 | ||
1684 | static inline void dlci_get(struct gsm_dlci *dlci) | 1682 | static inline void dlci_get(struct gsm_dlci *dlci) |
1685 | { | 1683 | { |
1686 | kref_get(&dlci->ref); | 1684 | tty_port_get(&dlci->port); |
1687 | } | 1685 | } |
1688 | 1686 | ||
1689 | static inline void dlci_put(struct gsm_dlci *dlci) | 1687 | static inline void dlci_put(struct gsm_dlci *dlci) |
1690 | { | 1688 | { |
1691 | kref_put(&dlci->ref, gsm_dlci_free); | 1689 | tty_port_put(&dlci->port); |
1692 | } | 1690 | } |
1693 | 1691 | ||
1694 | /** | 1692 | /** |
@@ -2874,6 +2872,7 @@ static void gsm_dtr_rts(struct tty_port *port, int onoff) | |||
2874 | static const struct tty_port_operations gsm_port_ops = { | 2872 | static const struct tty_port_operations gsm_port_ops = { |
2875 | .carrier_raised = gsm_carrier_raised, | 2873 | .carrier_raised = gsm_carrier_raised, |
2876 | .dtr_rts = gsm_dtr_rts, | 2874 | .dtr_rts = gsm_dtr_rts, |
2875 | .destruct = gsm_dlci_free, | ||
2877 | }; | 2876 | }; |
2878 | 2877 | ||
2879 | static int gsmtty_install(struct tty_driver *driver, struct tty_struct *tty) | 2878 | static int gsmtty_install(struct tty_driver *driver, struct tty_struct *tty) |