From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Nathael Pajani <nathael.pajani@ed3l.fr>,
Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 5/5] tty: fix tty_line must not be equal to number of allocated tty pointers in tty driver
Date: Fri, 3 Sep 2010 19:13:22 -0700 [thread overview]
Message-ID: <1283566402-28832-5-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20100904020937.GA28645@kroah.com>
From: Nathael Pajani <nathael.pajani@ed3l.fr>
I found a bug "by chance" in drivers/char/tty_io.c
I mean "by chance" because I was just reading the code of the
tty_find_polling_driver() to make a new tty_find_by_name() function.
In tty_find_polling_driver() the driver actually test "tty_line <=
p->num" while num refers to the number of struct tty_struct pointers
allocated for the p->ttys (p is a tty_driver), and tty_line is scanned
in a tty name, which can be for example ttyS2. Then tty_line equals 2.
And if p->num is 2, we have only p->ttys[0] and p->ttys[1], but no
p->ttys[2].
This is actually unharmful, for tty_find_polling_driver() is used only
in drivers/serial/kgdboc.c, and there's a test over there to find a
console with a matching index, which will never happen.
This is still a bug anyway.
Signed-off-by: Nathael Pajani <nathael.pajani@ed3l.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/char/tty_io.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 949067a..613c852 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -355,7 +355,7 @@ struct tty_driver *tty_find_polling_driver(char *name, int *line)
if (*stp == '\0')
stp = NULL;
- if (tty_line >= 0 && tty_line <= p->num && p->ops &&
+ if (tty_line >= 0 && tty_line < p->num && p->ops &&
p->ops->poll_init && !p->ops->poll_init(p, tty_line, stp)) {
res = tty_driver_kref_get(p);
*line = tty_line;
--
1.7.2
prev parent reply other threads:[~2010-09-04 2:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-04 2:09 [GIT PATCH] TTY fixes for 2.6.36-git Greg KH
2010-09-04 2:13 ` [PATCH 1/5] vt: Fix console corruption on driver hand-over Greg Kroah-Hartman
2010-09-04 2:13 ` [PATCH 2/5] MAINTAINERS: orphan isicom Greg Kroah-Hartman
2010-09-04 2:13 ` [PATCH 3/5] serial: fix port type conflict between NS16550A & U6_16550A Greg Kroah-Hartman
2010-09-04 2:13 ` Greg Kroah-Hartman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1283566402-28832-5-git-send-email-gregkh@suse.de \
--to=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=nathael.pajani@ed3l.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox