]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/tty/tty_io.c
Merge branch 'cve-2019-3016' into kvm-next-5.6
[linux.git] / drivers / tty / tty_io.c
index a81807b394d1013c53844d27e7cc0f41bbe6af15..d9f54c7d94f29e3d1266d9a9c4858a45a5f110c8 100644 (file)
@@ -1345,9 +1345,12 @@ struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx)
        if (!tty->port)
                tty->port = driver->ports[idx];
 
-       WARN_RATELIMIT(!tty->port,
-                       "%s: %s driver does not set tty->port. This will crash the kernel later. Fix the driver!\n",
-                       __func__, tty->driver->name);
+       if (WARN_RATELIMIT(!tty->port,
+                       "%s: %s driver does not set tty->port. This would crash the kernel. Fix the driver!\n",
+                       __func__, tty->driver->name)) {
+               retval = -EINVAL;
+               goto err_release_lock;
+       }
 
        retval = tty_ldisc_lock(tty, 5 * HZ);
        if (retval)
@@ -1925,7 +1928,6 @@ EXPORT_SYMBOL_GPL(tty_kopen);
 /**
  *     tty_open_by_driver      -       open a tty device
  *     @device: dev_t of device to open
- *     @inode: inode of device file
  *     @filp: file pointer to tty
  *
  *     Performs the driver lookup, checks for a reopen, or otherwise
@@ -1938,7 +1940,7 @@ EXPORT_SYMBOL_GPL(tty_kopen);
  *       - concurrent tty driver removal w/ lookup
  *       - concurrent tty removal from driver table
  */
-static struct tty_struct *tty_open_by_driver(dev_t device, struct inode *inode,
+static struct tty_struct *tty_open_by_driver(dev_t device,
                                             struct file *filp)
 {
        struct tty_struct *tty;
@@ -2030,7 +2032,7 @@ static int tty_open(struct inode *inode, struct file *filp)
 
        tty = tty_open_current_tty(device, filp);
        if (!tty)
-               tty = tty_open_by_driver(device, inode, filp);
+               tty = tty_open_by_driver(device, filp);
 
        if (IS_ERR(tty)) {
                tty_free_file(filp);