From patchwork Wed Apr 7 13:13:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cox X-Patchwork-Id: 49604 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 016B2B7D0D for ; Wed, 7 Apr 2010 23:09:21 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757840Ab0DGNJM (ORCPT ); Wed, 7 Apr 2010 09:09:12 -0400 Received: from earthlight.etchedpixels.co.uk ([81.2.110.250]:55212 "EHLO www.etchedpixels.co.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756470Ab0DGNJK (ORCPT ); Wed, 7 Apr 2010 09:09:10 -0400 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by www.etchedpixels.co.uk (8.14.3/8.14.3) with ESMTP id o37DDJn8029714; Wed, 7 Apr 2010 14:13:19 +0100 Date: Wed, 7 Apr 2010 14:13:19 +0100 From: Alan Cox To: Sjur BRENDELAND Cc: "netdev@vger.kernel.org" Subject: [PATCH] Caif: Ref counting Message-ID: <20100407141319.318ebb6f@lxorguk.ukuu.org.uk> In-Reply-To: <81C3A93C17462B4BBD7E272753C105791696B5DCF0@EXDCVYMBSTM005.EQ1STM.local> References: <20100401160916.2a2574f4@lxorguk.ukuu.org.uk> <81C3A93C17462B4BBD7E272753C105791696B5DCF0@EXDCVYMBSTM005.EQ1STM.local> X-Mailer: Claws Mail 3.7.5 (GTK+ 2.18.9; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org caif: tty's are kref objects so take a reference From: Alan Cox I don't think this can be abused in this case but do things properly. Signed-off-by: Alan Cox --- drivers/net/caif/caif_serial.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c index 3502f60..b271aa0 100644 --- a/drivers/net/caif/caif_serial.c +++ b/drivers/net/caif/caif_serial.c @@ -315,7 +315,7 @@ static int ldisc_open(struct tty_struct *tty) sprintf(name, "cf%s", tty->name); dev = alloc_netdev(sizeof(*ser), name, caifdev_setup); ser = netdev_priv(dev); - ser->tty = tty; + ser->tty = tty_kref_get(tty); ser->dev = dev; debugfs_init(ser, tty); tty->receive_room = N_TTY_BUF_SIZE; @@ -348,6 +348,7 @@ static void ldisc_close(struct tty_struct *tty) unregister_netdevice(ser->dev); list_del(&ser->node); debugfs_deinit(ser); + tty_kref_put(ser->tty); if (!islocked) rtnl_unlock(); }