Commit 410235fd authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman
Browse files

TTY: remove unneeded tty->index checks



Checking if tty->index is in bounds is not needed. The tty has the
index set in the initial open. This is done in get_tty_driver. And it
can be only in interval <0,driver->num).

So remove the tests which check exactly this interval. Some are
left untouched as they check against the current backing device count.
(Leaving apart that the check is racy in most of the cases.)

Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 44a1bfd9
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -769,13 +769,10 @@ errout:
static int rs_open(struct tty_struct *tty, struct file * filp)
{
	struct async_struct	*info;
	int			retval, line;
	int			retval;
	unsigned long		page;

	line = tty->index;
	if ((line < 0) || (line >= NR_PORTS))
		return -ENODEV;
	retval = get_async_struct(line, &info);
	retval = get_async_struct(tty->index, &info);
	if (retval)
		return retval;
	tty->driver_data = info;
@@ -920,7 +917,7 @@ simrs_init (void)
	if (!ia64_platform_is("hpsim"))
		return -ENODEV;

	hp_simserial_driver = alloc_tty_driver(1);
	hp_simserial_driver = alloc_tty_driver(NR_PORTS);
	if (!hp_simserial_driver)
		return -ENOMEM;

+2 −6
Original line number Diff line number Diff line
@@ -68,11 +68,6 @@ static void rs_poll(unsigned long);

static int rs_open(struct tty_struct *tty, struct file * filp)
{
	int line = tty->index;

	if ((line < 0) || (line >= SERIAL_MAX_NUM_LINES))
		return -ENODEV;

	spin_lock(&timer_lock);

	if (tty->count == 1) {
@@ -101,6 +96,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
{
	spin_lock(&timer_lock);
	if (tty->count == 1)
		/* this will cause a deadlock if the timer ticks right now */
		del_timer_sync(&serial_timer);
	spin_unlock(&timer_lock);
}
@@ -210,7 +206,7 @@ static const struct tty_operations serial_ops = {

int __init rs_init(void)
{
	serial_driver = alloc_tty_driver(1);
	serial_driver = alloc_tty_driver(SERIAL_MAX_NUM_LINES);

	printk ("%s %s\n", serial_name, serial_version);

+1 −1
Original line number Diff line number Diff line
@@ -2484,7 +2484,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)

	/* verify range of specified line number */
	line = tty->index;
	if ((line < 0) || (line >= mgslpc_device_count)) {
	if (line >= mgslpc_device_count) {
		printk("%s(%d):mgslpc_open with invalid line #%d.\n",
			__FILE__,__LINE__,line);
		return -ENODEV;
+1 −2
Original line number Diff line number Diff line
@@ -1013,8 +1013,7 @@ static const struct file_operations capi_fops =
static int
capinc_tty_install(struct tty_driver *driver, struct tty_struct *tty)
{
	int idx = tty->index;
	struct capiminor *mp = capiminor_get(idx);
	struct capiminor *mp = capiminor_get(tty->index);
	int ret = tty_standard_install(driver, tty);

	if (ret == 0)
+0 −2
Original line number Diff line number Diff line
@@ -1051,8 +1051,6 @@ static struct cardstate *gigaset_get_cs_by_minor(unsigned minor)

struct cardstate *gigaset_get_cs_by_tty(struct tty_struct *tty)
{
	if (tty->index < 0 || tty->index >= tty->driver->num)
		return NULL;
	return gigaset_get_cs_by_minor(tty->index + tty->driver->minor_start);
}

Loading