From: Jiri Slaby Date: Wed, 12 Oct 2011 09:32:42 +0000 (+0200) Subject: TTY: drop driver reference in tty_open fail path X-Git-Tag: v2.6.32.68~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d447af56f50bdcb4d5ca378ed6b2d48fb0b973ac;p=thirdparty%2Fkernel%2Fstable.git TTY: drop driver reference in tty_open fail path commit c290f8358acaeffd8e0c551ddcc24d1206143376 upstream. When tty_driver_lookup_tty fails in tty_open, we forget to drop a reference to the tty driver. This was added by commit 4a2b5fddd5 (Move tty lookup/reopen to caller). Fix that by adding tty_driver_kref_put to the fail path. I will refactor the code later. This is for the ease of backporting to stable. Introduced-in: v2.6.28-rc2 Signed-off-by: Jiri Slaby Cc: Alan Cox Acked-by: Sukadev Bhattiprolu Signed-off-by: Greg Kroah-Hartman [bwh: Backported to 2.6.32: adjust filename] Signed-off-by: Ben Hutchings CVE-2011-5321 Signed-off-by: Willy Tarreau --- diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index cbdd1698c07b8..6c7153438514d 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -1779,6 +1779,7 @@ got_driver: if (IS_ERR(tty)) { mutex_unlock(&tty_mutex); + tty_driver_kref_put(driver); return PTR_ERR(tty); } }