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: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

父節點
44a1bfd95d
當前提交
410235fd4d
@@ -1090,27 +1090,23 @@ static int hvcs_enable_device(struct hvcs_struct *hvcsd, uint32_t unit_address,
|
||||
*/
|
||||
static struct hvcs_struct *hvcs_get_by_index(int index)
|
||||
{
|
||||
struct hvcs_struct *hvcsd = NULL;
|
||||
struct hvcs_struct *hvcsd;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock(&hvcs_structs_lock);
|
||||
/* We can immediately discard OOB requests */
|
||||
if (index >= 0 && index < HVCS_MAX_SERVER_ADAPTERS) {
|
||||
list_for_each_entry(hvcsd, &hvcs_structs, next) {
|
||||
spin_lock_irqsave(&hvcsd->lock, flags);
|
||||
if (hvcsd->index == index) {
|
||||
kref_get(&hvcsd->kref);
|
||||
spin_unlock_irqrestore(&hvcsd->lock, flags);
|
||||
spin_unlock(&hvcs_structs_lock);
|
||||
return hvcsd;
|
||||
}
|
||||
list_for_each_entry(hvcsd, &hvcs_structs, next) {
|
||||
spin_lock_irqsave(&hvcsd->lock, flags);
|
||||
if (hvcsd->index == index) {
|
||||
kref_get(&hvcsd->kref);
|
||||
spin_unlock_irqrestore(&hvcsd->lock, flags);
|
||||
spin_unlock(&hvcs_structs_lock);
|
||||
return hvcsd;
|
||||
}
|
||||
hvcsd = NULL;
|
||||
spin_unlock_irqrestore(&hvcsd->lock, flags);
|
||||
}
|
||||
|
||||
spin_unlock(&hvcs_structs_lock);
|
||||
return hvcsd;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -737,14 +737,11 @@ static int hvsi_open(struct tty_struct *tty, struct file *filp)
|
||||
{
|
||||
struct hvsi_struct *hp;
|
||||
unsigned long flags;
|
||||
int line = tty->index;
|
||||
int ret;
|
||||
|
||||
pr_debug("%s\n", __func__);
|
||||
|
||||
if (line < 0 || line >= hvsi_count)
|
||||
return -ENODEV;
|
||||
hp = &hvsi_ports[line];
|
||||
hp = &hvsi_ports[tty->index];
|
||||
|
||||
tty->driver_data = hp;
|
||||
|
||||
|
Reference in New Issue
Block a user