aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tty_ldisc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/tty_ldisc.c')
-rw-r--r--drivers/char/tty_ldisc.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/char/tty_ldisc.c b/drivers/char/tty_ldisc.c
index 39c8f86dedd..a19e935847b 100644
--- a/drivers/char/tty_ldisc.c
+++ b/drivers/char/tty_ldisc.c
@@ -148,8 +148,10 @@ static struct tty_ldisc *tty_ldisc_try_get(int disc)
148 } 148 }
149 } 149 }
150 spin_unlock_irqrestore(&tty_ldisc_lock, flags); 150 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
151 if (err) 151 if (err) {
152 kfree(ld);
152 return ERR_PTR(err); 153 return ERR_PTR(err);
154 }
153 return ld; 155 return ld;
154} 156}
155 157
@@ -205,6 +207,7 @@ static void tty_ldisc_put(struct tty_ldisc *ld)
205 ldo->refcount--; 207 ldo->refcount--;
206 module_put(ldo->owner); 208 module_put(ldo->owner);
207 spin_unlock_irqrestore(&tty_ldisc_lock, flags); 209 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
210 WARN_ON(ld->refcount);
208 kfree(ld); 211 kfree(ld);
209} 212}
210 213
@@ -262,7 +265,7 @@ const struct file_operations tty_ldiscs_proc_fops = {
262 * @ld: line discipline 265 * @ld: line discipline
263 * 266 *
264 * Install an instance of a line discipline into a tty structure. The 267 * Install an instance of a line discipline into a tty structure. The
265 * ldisc must have a reference count above zero to ensure it remains/ 268 * ldisc must have a reference count above zero to ensure it remains.
266 * The tty instance refcount starts at zero. 269 * The tty instance refcount starts at zero.
267 * 270 *
268 * Locking: 271 * Locking:
@@ -791,6 +794,8 @@ void tty_ldisc_hangup(struct tty_struct *tty)
791 /* Avoid racing set_ldisc */ 794 /* Avoid racing set_ldisc */
792 mutex_lock(&tty->ldisc_mutex); 795 mutex_lock(&tty->ldisc_mutex);
793 /* Switch back to N_TTY */ 796 /* Switch back to N_TTY */
797 tty_ldisc_halt(tty);
798 tty_ldisc_wait_idle(tty);
794 tty_ldisc_reinit(tty); 799 tty_ldisc_reinit(tty);
795 /* At this point we have a closed ldisc and we want to 800 /* At this point we have a closed ldisc and we want to
796 reopen it. We could defer this to the next open but 801 reopen it. We could defer this to the next open but