Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763381AbYJMKBO (ORCPT ); Mon, 13 Oct 2008 06:01:14 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1762751AbYJMJoE (ORCPT ); Mon, 13 Oct 2008 05:44:04 -0400 Received: from earthlight.etchedpixels.co.uk ([81.2.110.250]:51022 "EHLO lxorguk.ukuu.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1762744AbYJMJoB (ORCPT ); Mon, 13 Oct 2008 05:44:01 -0400 From: Alan Cox Subject: [PATCH 68/80] pty: simplify unix98 allocation To: torvalds@linux-foundation.org, linux-kernel@vger.kernel.org Date: Mon, 13 Oct 2008 10:43:58 +0100 Message-ID: <20081013094353.21645.56724.stgit@localhost.localdomain> In-Reply-To: <20081013092758.21645.2359.stgit@localhost.localdomain> References: <20081013092758.21645.2359.stgit@localhost.localdomain> User-Agent: StGIT/0.14.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2279 Lines: 68 From: Alan Cox We need both termios and termios_locked so allocate them as one Signed-off-by: Alan Cox --- drivers/char/pty.c | 18 +++++++----------- 1 files changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/char/pty.c b/drivers/char/pty.c index 3c6b791..6d45827 100644 --- a/drivers/char/pty.c +++ b/drivers/char/pty.c @@ -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 */ kfree(tty->termios); - kfree(tty->termios_locked); } /* 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) } 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) goto free_mem_out; *tty->termios = driver->init_termios; - tty->termios_locked = kzalloc(sizeof(struct ktermios), GFP_KERNEL); - if (tty->termios_locked == NULL) - goto free_mem_out; - o_tty->termios = kmalloc(sizeof(struct ktermios), GFP_KERNEL); + tty->termios_locked = tty->termios + 1; + + o_tty->termios = kzalloc(sizeof(struct ktermios[2]), GFP_KERNEL); if (o_tty->termios == NULL) goto free_mem_out; *o_tty->termios = driver->other->init_termios; - o_tty->termios_locked = kzalloc(sizeof(struct ktermios), GFP_KERNEL); - if (o_tty->termios_locked == NULL) - goto free_mem_out; + o_tty->termios_locked = o_tty->termios + 1; tty_driver_kref_get(driver->other); if (driver->subtype == PTY_TYPE_MASTER) @@ -540,10 +536,10 @@ static int pty_unix98_install(struct tty_driver *driver, struct tty_struct *tty) pty_count++; return 0; free_mem_out: - pty_unix98_shutdown(o_tty); + kfree(o_tty->termios); module_put(o_tty->driver->owner); free_tty_struct(o_tty); - pty_unix98_shutdown(tty); + kfree(tty->termios); return -ENOMEM; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/