Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6d31a88c authored by Alan Cox's avatar Alan Cox Committed by Greg Kroah-Hartman
Browse files

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: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 467a3ca5
Loading
Loading
Loading
Loading
+7 −7
Original line number Original line Diff line number Diff line
@@ -1033,7 +1033,7 @@ static int get_serial_info(struct tty_struct *tty, struct serial_state *state,
	if (!retinfo)
	if (!retinfo)
		return -EFAULT;
		return -EFAULT;
	memset(&tmp, 0, sizeof(tmp));
	memset(&tmp, 0, sizeof(tmp));
	tty_lock(tty);
	tty_lock();
	tmp.line = tty->index;
	tmp.line = tty->index;
	tmp.port = state->port;
	tmp.port = state->port;
	tmp.flags = state->tport.flags;
	tmp.flags = state->tport.flags;
@@ -1042,7 +1042,7 @@ static int get_serial_info(struct tty_struct *tty, struct serial_state *state,
	tmp.close_delay = state->tport.close_delay;
	tmp.close_delay = state->tport.close_delay;
	tmp.closing_wait = state->tport.closing_wait;
	tmp.closing_wait = state->tport.closing_wait;
	tmp.custom_divisor = state->custom_divisor;
	tmp.custom_divisor = state->custom_divisor;
	tty_unlock(tty);
	tty_unlock();
	if (copy_to_user(retinfo,&tmp,sizeof(*retinfo)))
	if (copy_to_user(retinfo,&tmp,sizeof(*retinfo)))
		return -EFAULT;
		return -EFAULT;
	return 0;
	return 0;
@@ -1059,12 +1059,12 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
	if (copy_from_user(&new_serial,new_info,sizeof(new_serial)))
	if (copy_from_user(&new_serial,new_info,sizeof(new_serial)))
		return -EFAULT;
		return -EFAULT;


	tty_lock(tty);
	tty_lock();
	change_spd = ((new_serial.flags ^ port->flags) & ASYNC_SPD_MASK) ||
	change_spd = ((new_serial.flags ^ port->flags) & ASYNC_SPD_MASK) ||
		new_serial.custom_divisor != state->custom_divisor;
		new_serial.custom_divisor != state->custom_divisor;
	if (new_serial.irq || new_serial.port != state->port ||
	if (new_serial.irq || new_serial.port != state->port ||
			new_serial.xmit_fifo_size != state->xmit_fifo_size) {
			new_serial.xmit_fifo_size != state->xmit_fifo_size) {
		tty_unlock(tty);
		tty_unlock();
		return -EINVAL;
		return -EINVAL;
	}
	}
  
  
@@ -1074,7 +1074,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
		    (new_serial.xmit_fifo_size != state->xmit_fifo_size) ||
		    (new_serial.xmit_fifo_size != state->xmit_fifo_size) ||
		    ((new_serial.flags & ~ASYNC_USR_MASK) !=
		    ((new_serial.flags & ~ASYNC_USR_MASK) !=
		     (port->flags & ~ASYNC_USR_MASK))) {
		     (port->flags & ~ASYNC_USR_MASK))) {
			tty_unlock(tty);
			tty_unlock();
			return -EPERM;
			return -EPERM;
		}
		}
		port->flags = ((port->flags & ~ASYNC_USR_MASK) |
		port->flags = ((port->flags & ~ASYNC_USR_MASK) |
@@ -1084,7 +1084,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
	}
	}


	if (new_serial.baud_base < 9600) {
	if (new_serial.baud_base < 9600) {
		tty_unlock(tty);
		tty_unlock();
		return -EINVAL;
		return -EINVAL;
	}
	}


@@ -1116,7 +1116,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
		}
		}
	} else
	} else
		retval = startup(tty, state);
		retval = startup(tty, state);
	tty_unlock(tty);
	tty_unlock();
	return retval;
	return retval;
}
}


+1 −1
Original line number Original line Diff line number Diff line
@@ -1599,7 +1599,7 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
	 * If the port is the middle of closing, bail out now
	 * If the port is the middle of closing, bail out now
	 */
	 */
	if (tty_hung_up_p(filp) || (info->port.flags & ASYNC_CLOSING)) {
	if (tty_hung_up_p(filp) || (info->port.flags & ASYNC_CLOSING)) {
		wait_event_interruptible_tty(tty, info->port.close_wait,
		wait_event_interruptible_tty(info->port.close_wait,
				!(info->port.flags & ASYNC_CLOSING));
				!(info->port.flags & ASYNC_CLOSING));
		return (info->port.flags & ASYNC_HUP_NOTIFY) ? -EAGAIN: -ERESTARTSYS;
		return (info->port.flags & ASYNC_HUP_NOTIFY) ? -EAGAIN: -ERESTARTSYS;
	}
	}
+5 −5
Original line number Original line Diff line number Diff line
@@ -1065,7 +1065,7 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file,


	TRACE_L("read()");
	TRACE_L("read()");


	tty_lock(tty);
	tty_lock();


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


@@ -1107,7 +1107,7 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
	}
	}
	ret = -EPERM;
	ret = -EPERM;
unlock:
unlock:
	tty_unlock(tty);
	tty_unlock();
	return ret;
	return ret;
}
}


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


	tty_lock(tty);
	tty_lock();


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


	tty_unlock(tty);
	tty_unlock();


	return 0;
	return 0;
}
}
+11 −12
Original line number Original line Diff line number Diff line
@@ -47,7 +47,6 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
	wake_up_interruptible(&tty->read_wait);
	wake_up_interruptible(&tty->read_wait);
	wake_up_interruptible(&tty->write_wait);
	wake_up_interruptible(&tty->write_wait);
	tty->packet = 0;
	tty->packet = 0;
	/* Review - krefs on tty_link ?? */
	if (!tty->link)
	if (!tty->link)
		return;
		return;
	tty->link->packet = 0;
	tty->link->packet = 0;
@@ -63,9 +62,9 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
		        mutex_unlock(&devpts_mutex);
		        mutex_unlock(&devpts_mutex);
		}
		}
#endif
#endif
		tty_unlock(tty);
		tty_unlock();
		tty_vhangup(tty->link);
		tty_vhangup(tty->link);
		tty_lock(tty);
		tty_lock();
	}
	}
}
}


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


	/* find a device that is not in use. */
	/* find a device that is not in use. */
	mutex_lock(&devpts_mutex);
	tty_lock();
	index = devpts_new_index(inode);
	index = devpts_new_index(inode);
	mutex_unlock(&devpts_mutex);
	tty_unlock();
	if (index < 0) {
	if (index < 0) {
		retval = index;
		retval = index;
		goto err_file;
		goto err_file;
	}
	}


	mutex_lock(&tty_mutex);
	mutex_lock(&tty_mutex);
	mutex_lock(&devpts_mutex);
	tty = tty_init_dev(ptm_driver, index);
	tty = tty_init_dev(ptm_driver, index);
	mutex_unlock(&devpts_mutex);
	tty_lock();
	mutex_unlock(&tty_mutex);


	if (IS_ERR(tty)) {
	if (IS_ERR(tty)) {
		retval = PTR_ERR(tty);
		retval = PTR_ERR(tty);
		goto out;
		goto out;
	}
	}


	/* The tty returned here is locked so we can safely
	   drop the mutex */
	mutex_unlock(&tty_mutex);

	set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */
	set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */


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


	tty_unlock(tty);
	tty_unlock();
	return 0;
	return 0;
err_release:
err_release:
	tty_unlock(tty);
	tty_unlock();
	tty_release(inode, filp);
	tty_release(inode, filp);
	return retval;
	return retval;
out:
out:
	mutex_unlock(&tty_mutex);
	devpts_kill_index(inode, index);
	devpts_kill_index(inode, index);
	tty_unlock();
err_file:
err_file:
	tty_free_file(filp);
	tty_free_file(filp);
	return retval;
	return retval;
+4 −4
Original line number Original line Diff line number Diff line
@@ -3976,7 +3976,7 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
	 */
	 */
	if (tty_hung_up_p(filp) ||
	if (tty_hung_up_p(filp) ||
	    (info->flags & ASYNC_CLOSING)) {
	    (info->flags & ASYNC_CLOSING)) {
		wait_event_interruptible_tty(tty, info->close_wait,
		wait_event_interruptible_tty(info->close_wait,
			!(info->flags & ASYNC_CLOSING));
			!(info->flags & ASYNC_CLOSING));
#ifdef SERIAL_DO_RESTART
#ifdef SERIAL_DO_RESTART
		if (info->flags & ASYNC_HUP_NOTIFY)
		if (info->flags & ASYNC_HUP_NOTIFY)
@@ -4052,9 +4052,9 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
		printk("block_til_ready blocking: ttyS%d, count = %d\n",
		printk("block_til_ready blocking: ttyS%d, count = %d\n",
		       info->line, info->count);
		       info->line, info->count);
#endif
#endif
		tty_unlock(tty);
		tty_unlock();
		schedule();
		schedule();
		tty_lock(tty);
		tty_lock();
	}
	}
	set_current_state(TASK_RUNNING);
	set_current_state(TASK_RUNNING);
	remove_wait_queue(&info->open_wait, &wait);
	remove_wait_queue(&info->open_wait, &wait);
@@ -4115,7 +4115,7 @@ rs_open(struct tty_struct *tty, struct file * filp)
	 */
	 */
	if (tty_hung_up_p(filp) ||
	if (tty_hung_up_p(filp) ||
	    (info->flags & ASYNC_CLOSING)) {
	    (info->flags & ASYNC_CLOSING)) {
		wait_event_interruptible_tty(tty, info->close_wait,
		wait_event_interruptible_tty(info->close_wait,
			!(info->flags & ASYNC_CLOSING));
			!(info->flags & ASYNC_CLOSING));
#ifdef SERIAL_DO_RESTART
#ifdef SERIAL_DO_RESTART
		return ((info->flags & ASYNC_HUP_NOTIFY) ?
		return ((info->flags & ASYNC_HUP_NOTIFY) ?
Loading