Skip to content

Commit 6d31a88

Browse files
Alan Coxgregkh
authored andcommitted
tty: revert incorrectly applied lock patch
I sent GregKH this after the pre-requisites. He dropped the pre-requesites for good reason and unfortunately then applied this patch. Without this reverted you get random kernel memory corruption which will make bisecting anything between it and the properly applied patches a complete sod. Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 467a3ca commit 6d31a88

14 files changed

Lines changed: 119 additions & 188 deletions

File tree

‎drivers/tty/amiserial.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ static int get_serial_info(struct tty_struct *tty, struct serial_state *state,
10331033
if (!retinfo)
10341034
return -EFAULT;
10351035
memset(&tmp, 0, sizeof(tmp));
1036-
tty_lock(tty);
1036+
tty_lock();
10371037
tmp.line = tty->index;
10381038
tmp.port = state->port;
10391039
tmp.flags = state->tport.flags;
@@ -1042,7 +1042,7 @@ static int get_serial_info(struct tty_struct *tty, struct serial_state *state,
10421042
tmp.close_delay = state->tport.close_delay;
10431043
tmp.closing_wait = state->tport.closing_wait;
10441044
tmp.custom_divisor = state->custom_divisor;
1045-
tty_unlock(tty);
1045+
tty_unlock();
10461046
if (copy_to_user(retinfo,&tmp,sizeof(*retinfo)))
10471047
return -EFAULT;
10481048
return 0;
@@ -1059,12 +1059,12 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
10591059
if (copy_from_user(&new_serial,new_info,sizeof(new_serial)))
10601060
return -EFAULT;
10611061

1062-
tty_lock(tty);
1062+
tty_lock();
10631063
change_spd = ((new_serial.flags ^ port->flags) & ASYNC_SPD_MASK) ||
10641064
new_serial.custom_divisor != state->custom_divisor;
10651065
if (new_serial.irq || new_serial.port != state->port ||
10661066
new_serial.xmit_fifo_size != state->xmit_fifo_size) {
1067-
tty_unlock(tty);
1067+
tty_unlock();
10681068
return -EINVAL;
10691069
}
10701070

@@ -1074,7 +1074,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
10741074
(new_serial.xmit_fifo_size != state->xmit_fifo_size) ||
10751075
((new_serial.flags & ~ASYNC_USR_MASK) !=
10761076
(port->flags & ~ASYNC_USR_MASK))) {
1077-
tty_unlock(tty);
1077+
tty_unlock();
10781078
return -EPERM;
10791079
}
10801080
port->flags = ((port->flags & ~ASYNC_USR_MASK) |
@@ -1084,7 +1084,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
10841084
}
10851085

10861086
if (new_serial.baud_base < 9600) {
1087-
tty_unlock(tty);
1087+
tty_unlock();
10881088
return -EINVAL;
10891089
}
10901090

@@ -1116,7 +1116,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
11161116
}
11171117
} else
11181118
retval = startup(tty, state);
1119-
tty_unlock(tty);
1119+
tty_unlock();
11201120
return retval;
11211121
}
11221122

‎drivers/tty/cyclades.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
15991599
* If the port is the middle of closing, bail out now
16001600
*/
16011601
if (tty_hung_up_p(filp) || (info->port.flags & ASYNC_CLOSING)) {
1602-
wait_event_interruptible_tty(tty, info->port.close_wait,
1602+
wait_event_interruptible_tty(info->port.close_wait,
16031603
!(info->port.flags & ASYNC_CLOSING));
16041604
return (info->port.flags & ASYNC_HUP_NOTIFY) ? -EAGAIN: -ERESTARTSYS;
16051605
}

‎drivers/tty/n_r3964.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
10651065

10661066
TRACE_L("read()");
10671067

1068-
tty_lock(tty);
1068+
tty_lock();
10691069

10701070
pClient = findClient(pInfo, task_pid(current));
10711071
if (pClient) {
@@ -1077,7 +1077,7 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
10771077
goto unlock;
10781078
}
10791079
/* block until there is a message: */
1080-
wait_event_interruptible_tty(tty, pInfo->read_wait,
1080+
wait_event_interruptible_tty(pInfo->read_wait,
10811081
(pMsg = remove_msg(pInfo, pClient)));
10821082
}
10831083

@@ -1107,7 +1107,7 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
11071107
}
11081108
ret = -EPERM;
11091109
unlock:
1110-
tty_unlock(tty);
1110+
tty_unlock();
11111111
return ret;
11121112
}
11131113

@@ -1156,7 +1156,7 @@ static ssize_t r3964_write(struct tty_struct *tty, struct file *file,
11561156
pHeader->locks = 0;
11571157
pHeader->owner = NULL;
11581158

1159-
tty_lock(tty);
1159+
tty_lock();
11601160

11611161
pClient = findClient(pInfo, task_pid(current));
11621162
if (pClient) {
@@ -1175,7 +1175,7 @@ static ssize_t r3964_write(struct tty_struct *tty, struct file *file,
11751175
add_tx_queue(pInfo, pHeader);
11761176
trigger_transmit(pInfo);
11771177

1178-
tty_unlock(tty);
1178+
tty_unlock();
11791179

11801180
return 0;
11811181
}

‎drivers/tty/pty.c‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
4747
wake_up_interruptible(&tty->read_wait);
4848
wake_up_interruptible(&tty->write_wait);
4949
tty->packet = 0;
50-
/* Review - krefs on tty_link ?? */
5150
if (!tty->link)
5251
return;
5352
tty->link->packet = 0;
@@ -63,9 +62,9 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
6362
mutex_unlock(&devpts_mutex);
6463
}
6564
#endif
66-
tty_unlock(tty);
65+
tty_unlock();
6766
tty_vhangup(tty->link);
68-
tty_lock(tty);
67+
tty_lock();
6968
}
7069
}
7170

@@ -616,26 +615,26 @@ static int ptmx_open(struct inode *inode, struct file *filp)
616615
return retval;
617616

618617
/* find a device that is not in use. */
619-
mutex_lock(&devpts_mutex);
618+
tty_lock();
620619
index = devpts_new_index(inode);
621-
mutex_unlock(&devpts_mutex);
620+
tty_unlock();
622621
if (index < 0) {
623622
retval = index;
624623
goto err_file;
625624
}
626625

627626
mutex_lock(&tty_mutex);
627+
mutex_lock(&devpts_mutex);
628628
tty = tty_init_dev(ptm_driver, index);
629+
mutex_unlock(&devpts_mutex);
630+
tty_lock();
631+
mutex_unlock(&tty_mutex);
629632

630633
if (IS_ERR(tty)) {
631634
retval = PTR_ERR(tty);
632635
goto out;
633636
}
634637

635-
/* The tty returned here is locked so we can safely
636-
drop the mutex */
637-
mutex_unlock(&tty_mutex);
638-
639638
set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */
640639

641640
tty_add_file(tty, filp);
@@ -648,15 +647,15 @@ static int ptmx_open(struct inode *inode, struct file *filp)
648647
if (retval)
649648
goto err_release;
650649

651-
tty_unlock(tty);
650+
tty_unlock();
652651
return 0;
653652
err_release:
654-
tty_unlock(tty);
653+
tty_unlock();
655654
tty_release(inode, filp);
656655
return retval;
657656
out:
658-
mutex_unlock(&tty_mutex);
659657
devpts_kill_index(inode, index);
658+
tty_unlock();
660659
err_file:
661660
tty_free_file(filp);
662661
return retval;

‎drivers/tty/serial/crisv10.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3976,7 +3976,7 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
39763976
*/
39773977
if (tty_hung_up_p(filp) ||
39783978
(info->flags & ASYNC_CLOSING)) {
3979-
wait_event_interruptible_tty(tty, info->close_wait,
3979+
wait_event_interruptible_tty(info->close_wait,
39803980
!(info->flags & ASYNC_CLOSING));
39813981
#ifdef SERIAL_DO_RESTART
39823982
if (info->flags & ASYNC_HUP_NOTIFY)
@@ -4052,9 +4052,9 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
40524052
printk("block_til_ready blocking: ttyS%d, count = %d\n",
40534053
info->line, info->count);
40544054
#endif
4055-
tty_unlock(tty);
4055+
tty_unlock();
40564056
schedule();
4057-
tty_lock(tty);
4057+
tty_lock();
40584058
}
40594059
set_current_state(TASK_RUNNING);
40604060
remove_wait_queue(&info->open_wait, &wait);
@@ -4115,7 +4115,7 @@ rs_open(struct tty_struct *tty, struct file * filp)
41154115
*/
41164116
if (tty_hung_up_p(filp) ||
41174117
(info->flags & ASYNC_CLOSING)) {
4118-
wait_event_interruptible_tty(tty, info->close_wait,
4118+
wait_event_interruptible_tty(info->close_wait,
41194119
!(info->flags & ASYNC_CLOSING));
41204120
#ifdef SERIAL_DO_RESTART
41214121
return ((info->flags & ASYNC_HUP_NOTIFY) ?

‎drivers/tty/synclink.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3338,9 +3338,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
33383338
printk("%s(%d):block_til_ready blocking on %s count=%d\n",
33393339
__FILE__,__LINE__, tty->driver->name, port->count );
33403340

3341-
tty_unlock(tty);
3341+
tty_unlock();
33423342
schedule();
3343-
tty_lock(tty);
3343+
tty_lock();
33443344
}
33453345

33463346
set_current_state(TASK_RUNNING);

‎drivers/tty/synclink_gt.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3336,9 +3336,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
33363336
}
33373337

33383338
DBGINFO(("%s block_til_ready wait\n", tty->driver->name));
3339-
tty_unlock(tty);
3339+
tty_unlock();
33403340
schedule();
3341-
tty_lock(tty);
3341+
tty_lock();
33423342
}
33433343

33443344
set_current_state(TASK_RUNNING);

‎drivers/tty/synclinkmp.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3357,9 +3357,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
33573357
printk("%s(%d):%s block_til_ready() count=%d\n",
33583358
__FILE__,__LINE__, tty->driver->name, port->count );
33593359

3360-
tty_unlock(tty);
3360+
tty_unlock();
33613361
schedule();
3362-
tty_lock(tty);
3362+
tty_lock();
33633363
}
33643364

33653365
set_current_state(TASK_RUNNING);

0 commit comments

Comments
 (0)