Commit 844cc5f9 authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman

n_hdlc: remove checking of n_hdlc

We got rid of backup_tty recently. Also, the tty layer ensures not to
call other ldisc hooks after ldisc close. That means, all those tests
are superfluous now so remove them.

Note that we remove the magic check in write after schedule too. The tty
cannot change during schedule.
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20200219084118.26491-14-jslaby@suse.czSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent df6de639
...@@ -227,9 +227,6 @@ static void n_hdlc_tty_close(struct tty_struct *tty) ...@@ -227,9 +227,6 @@ static void n_hdlc_tty_close(struct tty_struct *tty)
{ {
struct n_hdlc *n_hdlc = tty->disc_data; struct n_hdlc *n_hdlc = tty->disc_data;
if (!n_hdlc)
return;
if (n_hdlc->magic != HDLC_MAGIC) { if (n_hdlc->magic != HDLC_MAGIC) {
printk(KERN_WARNING "n_hdlc: trying to close unopened tty!\n"); printk(KERN_WARNING "n_hdlc: trying to close unopened tty!\n");
return; return;
...@@ -383,11 +380,7 @@ static void n_hdlc_tty_wakeup(struct tty_struct *tty) ...@@ -383,11 +380,7 @@ static void n_hdlc_tty_wakeup(struct tty_struct *tty)
{ {
struct n_hdlc *n_hdlc = tty->disc_data; struct n_hdlc *n_hdlc = tty->disc_data;
if (!n_hdlc)
return;
n_hdlc_send_frames (n_hdlc, tty); n_hdlc_send_frames (n_hdlc, tty);
} /* end of n_hdlc_tty_wakeup() */ } /* end of n_hdlc_tty_wakeup() */
/** /**
...@@ -409,10 +402,6 @@ static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data, ...@@ -409,10 +402,6 @@ static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data,
pr_debug("%s(%d)%s() called count=%d\n", pr_debug("%s(%d)%s() called count=%d\n",
__FILE__, __LINE__, __func__, count); __FILE__, __LINE__, __func__, count);
/* This can happen if stuff comes in on the backup tty */
if (!n_hdlc)
return;
/* verify line is using HDLC discipline */ /* verify line is using HDLC discipline */
if (n_hdlc->magic != HDLC_MAGIC) { if (n_hdlc->magic != HDLC_MAGIC) {
printk("%s(%d) line not using HDLC discipline\n", printk("%s(%d) line not using HDLC discipline\n",
...@@ -473,10 +462,6 @@ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file, ...@@ -473,10 +462,6 @@ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
struct n_hdlc_buf *rbuf; struct n_hdlc_buf *rbuf;
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
/* Validate the pointers */
if (!n_hdlc)
return -EIO;
/* verify user access to buffer */ /* verify user access to buffer */
if (!access_ok(buf, nr)) { if (!access_ok(buf, nr)) {
printk(KERN_WARNING "%s(%d) n_hdlc_tty_read() can't verify user " printk(KERN_WARNING "%s(%d) n_hdlc_tty_read() can't verify user "
...@@ -558,10 +543,6 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file, ...@@ -558,10 +543,6 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
pr_debug("%s(%d)%s() called count=%zd\n", __FILE__, __LINE__, __func__, pr_debug("%s(%d)%s() called count=%zd\n", __FILE__, __LINE__, __func__,
count); count);
/* Verify pointers */
if (!n_hdlc)
return -EIO;
if (n_hdlc->magic != HDLC_MAGIC) if (n_hdlc->magic != HDLC_MAGIC)
return -EIO; return -EIO;
...@@ -587,13 +568,6 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file, ...@@ -587,13 +568,6 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
} }
schedule(); schedule();
n_hdlc = tty->disc_data;
if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC) {
printk("n_hdlc_tty_write: %p invalid after wait!\n", n_hdlc);
error = -EIO;
break;
}
if (signal_pending(current)) { if (signal_pending(current)) {
error = -EINTR; error = -EINTR;
break; break;
...@@ -638,7 +612,7 @@ static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file, ...@@ -638,7 +612,7 @@ static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file,
pr_debug("%s(%d)%s() called %d\n", __FILE__, __LINE__, __func__, cmd); pr_debug("%s(%d)%s() called %d\n", __FILE__, __LINE__, __func__, cmd);
/* Verify the status of the device */ /* Verify the status of the device */
if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC) if (n_hdlc->magic != HDLC_MAGIC)
return -EBADF; return -EBADF;
switch (cmd) { switch (cmd) {
...@@ -701,7 +675,7 @@ static __poll_t n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp, ...@@ -701,7 +675,7 @@ static __poll_t n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp,
struct n_hdlc *n_hdlc = tty->disc_data; struct n_hdlc *n_hdlc = tty->disc_data;
__poll_t mask = 0; __poll_t mask = 0;
if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC) if (n_hdlc->magic != HDLC_MAGIC)
return 0; return 0;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment