if (retval < 0)
goto err_deinit_tty;
+ if (!tty->port)
+ tty->port = driver->ports[idx];
+
/*
* Structures all installed ... call the ldisc open routines.
* If we fail here just call release_tty to clean up. No need
kfree(p);
cdev_del(&driver->cdev);
}
+ kfree(driver->ports);
kfree(driver);
}
if (!p)
return -ENOMEM;
}
+ /*
+ * There is too many lines in PTY and we won't need the array there
+ * since it has an ->install hook where it assigns ports properly.
+ */
+ if (driver->type != TTY_DRIVER_TYPE_PTY) {
+ driver->ports = kcalloc(driver->num, sizeof(struct tty_port *),
+ GFP_KERNEL);
+ if (!driver->ports) {
+ error = -ENOMEM;
+ goto err_free_p;
+ }
+ }
if (!driver->major) {
error = alloc_chrdev_region(&dev, driver->minor_start,
unregister_chrdev_region(dev, driver->num);
driver->ttys = NULL;
driver->termios = NULL;
-err_free_p:
+err_free_p: /* destruct_tty_driver will free driver->ports */
kfree(p);
return error;
}
* Pointer to the tty data structures
*/
struct tty_struct **ttys;
+ struct tty_port **ports;
struct ktermios **termios;
void *driver_state;