Skip to contentSkip to conversation

tty: Fix leaks introduced by the shift to separate ldisc objects

PATCH New Alan Cox 1 participant 1 message Jun 15, 2009 Char and misc drivers

lore
Share & tools
lore

Alan Cox

author
#0 lore raw

PATCH 1/1 tty: Fix leaks introduced by the shift to separate ldisc objects

From: Alan Cox <[email protected]>

Gold star for the kmemleak detector.

---

 drivers/char/tty_ldisc.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/char/tty_ldisc.c +4 -2
index 39c8f86..94b3e06 100644
@@ -148,8 +148,10 @@ static struct tty_ldisc *tty_ldisc_try_get(int disc)
 		}
 	}
 	spin_unlock_irqrestore(&tty_ldisc_lock, flags);
-	if (err)
+	if (err) {
+		kfree(ld);
 		return ERR_PTR(err);
+	}
 	return ld;
 }
 
@@ -262,7 +264,7 @@ const struct file_operations tty_ldiscs_proc_fops = {
  *	@ld: line discipline
  *
  *	Install an instance of a line discipline into a tty structure. The
- *	ldisc must have a reference count above zero to ensure it remains/
+ *	ldisc must have a reference count above zero to ensure it remains.
  *	The tty instance refcount starts at zero.
  *
  *	Locking: