diff options
author | Jiri Slaby <jslaby@suse.cz> | 2012-03-05 08:52:02 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-03-08 14:42:21 -0500 |
commit | ecaa3bda65cefebfce11cc7be4b8d9203f5ce12c (patch) | |
tree | 3e7a22ce001e18ce11b0cfc8902502708adb2b5a /drivers/tty | |
parent | 410235fd4d20b8feaf8930a0575d23acc088aa87 (diff) |
TTY: ipwireless, fix tty->index handling
* do not test if tty->index is in bounds. It is always.
* tty->index is not a minor! Fix that.
>From now on, let's assume that the parameter of the function is tty
index with base being zero. This makes also the code more readable.
Factually, there is no real change as tty_driver->minor_start is zero,
so the tests are equivalent. But it did not make sense. And if this
had changed eventually, it would have caused troubles.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Cc: David Sterba <dsterba@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/ipwireless/tty.c | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c index 6990b3b649d3..77ceaa9c9e3f 100644 --- a/drivers/tty/ipwireless/tty.c +++ b/drivers/tty/ipwireless/tty.c | |||
@@ -90,33 +90,23 @@ static void report_deregistering(struct ipw_tty *tty) | |||
90 | tty->index); | 90 | tty->index); |
91 | } | 91 | } |
92 | 92 | ||
93 | static struct ipw_tty *get_tty(int minor) | 93 | static struct ipw_tty *get_tty(int index) |
94 | { | 94 | { |
95 | if (minor < ipw_tty_driver->minor_start | 95 | /* |
96 | || minor >= ipw_tty_driver->minor_start + | 96 | * The 'ras_raw' channel is only available when 'loopback' mode |
97 | IPWIRELESS_PCMCIA_MINORS) | 97 | * is enabled. |
98 | * Number of minor starts with 16 (_RANGE * _RAS_RAW). | ||
99 | */ | ||
100 | if (!ipwireless_loopback && index >= | ||
101 | IPWIRELESS_PCMCIA_MINOR_RANGE * TTYTYPE_RAS_RAW) | ||
98 | return NULL; | 102 | return NULL; |
99 | else { | 103 | |
100 | int minor_offset = minor - ipw_tty_driver->minor_start; | 104 | return ttys[index]; |
101 | |||
102 | /* | ||
103 | * The 'ras_raw' channel is only available when 'loopback' mode | ||
104 | * is enabled. | ||
105 | * Number of minor starts with 16 (_RANGE * _RAS_RAW). | ||
106 | */ | ||
107 | if (!ipwireless_loopback && | ||
108 | minor_offset >= | ||
109 | IPWIRELESS_PCMCIA_MINOR_RANGE * TTYTYPE_RAS_RAW) | ||
110 | return NULL; | ||
111 | |||
112 | return ttys[minor_offset]; | ||
113 | } | ||
114 | } | 105 | } |
115 | 106 | ||
116 | static int ipw_open(struct tty_struct *linux_tty, struct file *filp) | 107 | static int ipw_open(struct tty_struct *linux_tty, struct file *filp) |
117 | { | 108 | { |
118 | int minor = linux_tty->index; | 109 | struct ipw_tty *tty = get_tty(linux_tty->index); |
119 | struct ipw_tty *tty = get_tty(minor); | ||
120 | 110 | ||
121 | if (!tty) | 111 | if (!tty) |
122 | return -ENODEV; | 112 | return -ENODEV; |
@@ -510,7 +500,7 @@ static int add_tty(int j, | |||
510 | ipwireless_associate_network_tty(network, | 500 | ipwireless_associate_network_tty(network, |
511 | secondary_channel_idx, | 501 | secondary_channel_idx, |
512 | ttys[j]); | 502 | ttys[j]); |
513 | if (get_tty(j + ipw_tty_driver->minor_start) == ttys[j]) | 503 | if (get_tty(j) == ttys[j]) |
514 | report_registering(ttys[j]); | 504 | report_registering(ttys[j]); |
515 | return 0; | 505 | return 0; |
516 | } | 506 | } |
@@ -570,7 +560,7 @@ void ipwireless_tty_free(struct ipw_tty *tty) | |||
570 | 560 | ||
571 | if (ttyj) { | 561 | if (ttyj) { |
572 | mutex_lock(&ttyj->ipw_tty_mutex); | 562 | mutex_lock(&ttyj->ipw_tty_mutex); |
573 | if (get_tty(j + ipw_tty_driver->minor_start) == ttyj) | 563 | if (get_tty(j) == ttyj) |
574 | report_deregistering(ttyj); | 564 | report_deregistering(ttyj); |
575 | ttyj->closing = 1; | 565 | ttyj->closing = 1; |
576 | if (ttyj->linux_tty != NULL) { | 566 | if (ttyj->linux_tty != NULL) { |