提交 8dff04ea 编写于 作者: A Alan Cox 提交者: Linus Torvalds

pty: simplify unix98 allocation

We need both termios and termios_locked so allocate them as one
Signed-off-by: NAlan Cox <alan@redhat.com>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 335adde6
...@@ -488,7 +488,6 @@ static void pty_unix98_shutdown(struct tty_struct *tty) ...@@ -488,7 +488,6 @@ static void pty_unix98_shutdown(struct tty_struct *tty)
{ {
/* We have our own method as we don't use the tty index */ /* We have our own method as we don't use the tty index */
kfree(tty->termios); kfree(tty->termios);
kfree(tty->termios_locked);
} }
/* We have no need to install and remove our tty objects as devpts does all /* We have no need to install and remove our tty objects as devpts does all
...@@ -509,20 +508,17 @@ static int pty_unix98_install(struct tty_driver *driver, struct tty_struct *tty) ...@@ -509,20 +508,17 @@ static int pty_unix98_install(struct tty_driver *driver, struct tty_struct *tty)
} }
initialize_tty_struct(o_tty, driver->other, idx); initialize_tty_struct(o_tty, driver->other, idx);
tty->termios = kmalloc(sizeof(struct ktermios), GFP_KERNEL); tty->termios = kzalloc(sizeof(struct ktermios[2]), GFP_KERNEL);
if (tty->termios == NULL) if (tty->termios == NULL)
goto free_mem_out; goto free_mem_out;
*tty->termios = driver->init_termios; *tty->termios = driver->init_termios;
tty->termios_locked = kzalloc(sizeof(struct ktermios), GFP_KERNEL); tty->termios_locked = tty->termios + 1;
if (tty->termios_locked == NULL)
goto free_mem_out; o_tty->termios = kzalloc(sizeof(struct ktermios[2]), GFP_KERNEL);
o_tty->termios = kmalloc(sizeof(struct ktermios), GFP_KERNEL);
if (o_tty->termios == NULL) if (o_tty->termios == NULL)
goto free_mem_out; goto free_mem_out;
*o_tty->termios = driver->other->init_termios; *o_tty->termios = driver->other->init_termios;
o_tty->termios_locked = kzalloc(sizeof(struct ktermios), GFP_KERNEL); o_tty->termios_locked = o_tty->termios + 1;
if (o_tty->termios_locked == NULL)
goto free_mem_out;
tty_driver_kref_get(driver->other); tty_driver_kref_get(driver->other);
if (driver->subtype == PTY_TYPE_MASTER) if (driver->subtype == PTY_TYPE_MASTER)
...@@ -540,10 +536,10 @@ static int pty_unix98_install(struct tty_driver *driver, struct tty_struct *tty) ...@@ -540,10 +536,10 @@ static int pty_unix98_install(struct tty_driver *driver, struct tty_struct *tty)
pty_count++; pty_count++;
return 0; return 0;
free_mem_out: free_mem_out:
pty_unix98_shutdown(o_tty); kfree(o_tty->termios);
module_put(o_tty->driver->owner); module_put(o_tty->driver->owner);
free_tty_struct(o_tty); free_tty_struct(o_tty);
pty_unix98_shutdown(tty); kfree(tty->termios);
return -ENOMEM; return -ENOMEM;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册