提交 b670bde0 编写于 作者: V Vasiliy Kulikov 提交者: Greg Kroah-Hartman

tty_io: check return code of tty_register_device

Function tty_register_device may return ERR_PTR(...). Check for it.
Signed-off-by: NVasiliy Kulikov <segooon@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 df480518
...@@ -3004,6 +3004,7 @@ int tty_register_driver(struct tty_driver *driver) ...@@ -3004,6 +3004,7 @@ int tty_register_driver(struct tty_driver *driver)
int i; int i;
dev_t dev; dev_t dev;
void **p = NULL; void **p = NULL;
struct device *d;
if (!(driver->flags & TTY_DRIVER_DEVPTS_MEM) && driver->num) { if (!(driver->flags & TTY_DRIVER_DEVPTS_MEM) && driver->num) {
p = kzalloc(driver->num * 2 * sizeof(void *), GFP_KERNEL); p = kzalloc(driver->num * 2 * sizeof(void *), GFP_KERNEL);
...@@ -3051,12 +3052,31 @@ int tty_register_driver(struct tty_driver *driver) ...@@ -3051,12 +3052,31 @@ int tty_register_driver(struct tty_driver *driver)
mutex_unlock(&tty_mutex); mutex_unlock(&tty_mutex);
if (!(driver->flags & TTY_DRIVER_DYNAMIC_DEV)) { if (!(driver->flags & TTY_DRIVER_DYNAMIC_DEV)) {
for (i = 0; i < driver->num; i++) for (i = 0; i < driver->num; i++) {
tty_register_device(driver, i, NULL); d = tty_register_device(driver, i, NULL);
if (IS_ERR(d)) {
error = PTR_ERR(d);
goto err;
}
}
} }
proc_tty_register_driver(driver); proc_tty_register_driver(driver);
driver->flags |= TTY_DRIVER_INSTALLED; driver->flags |= TTY_DRIVER_INSTALLED;
return 0; return 0;
err:
for (i--; i >= 0; i--)
tty_unregister_device(driver, i);
mutex_lock(&tty_mutex);
list_del(&driver->tty_drivers);
mutex_unlock(&tty_mutex);
unregister_chrdev_region(dev, driver->num);
driver->ttys = NULL;
driver->termios = NULL;
kfree(p);
return error;
} }
EXPORT_SYMBOL(tty_register_driver); EXPORT_SYMBOL(tty_register_driver);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册