From patchwork Thu May 29 08:48:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 31105 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f71.google.com (mail-pb0-f71.google.com [209.85.160.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D732320068 for ; Thu, 29 May 2014 08:49:05 +0000 (UTC) Received: by mail-pb0-f71.google.com with SMTP id jt11sf128074pbb.2 for ; Thu, 29 May 2014 01:49:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=mNo/HGNTJUTifrkL80r7itNHuYcqO8l+U0qk3vh/r+s=; b=T2o3if46DLlt0zs4j99SFmSoopkKmZmBhdA+Tdfpqzd+a1vDaLNFu8OpP+utJ83TfU VHBGtRdC2KBJOr9saZydDLtv1T22DvyfBoTfzFo/tdV9oBCsPBRxVs1PmbhdhbDF1QjD Hor9NwYvuRVhAYpknjPVhLNT50X0RNoaAkSKz1FpY/7fPkUQ8RP34EiNuQMRDEJN2r54 y9Rb8u2FZfUW0oxV7S/ZM/IVLA21b6lScAbLJY7R3p3z6D/kBd6aMkZ6dVu0NSWDl2+c 8LujY45RjDLX7D4SgWL7eAkLDBtzGhGC8JtbZDKcseRaDFG0P5+Sh1cazg4Fyq1vmdmW locQ== X-Gm-Message-State: ALoCoQmuRonNnglMqN6nsjziuWuzM1MhA4ShKy4Xm1P8wkcyhLwXGp0wl9Dva9/DldH/F4/DHVvy X-Received: by 10.68.230.193 with SMTP id ta1mr2288341pbc.6.1401353345125; Thu, 29 May 2014 01:49:05 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.28.4 with SMTP id 4ls463651qgy.39.gmail; Thu, 29 May 2014 01:49:04 -0700 (PDT) X-Received: by 10.58.198.107 with SMTP id jb11mr5288112vec.10.1401353344965; Thu, 29 May 2014 01:49:04 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id ir5si12704855vcb.82.2014.05.29.01.49.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 May 2014 01:49:04 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id la4so30695vcb.1 for ; Thu, 29 May 2014 01:49:04 -0700 (PDT) X-Received: by 10.221.42.135 with SMTP id ty7mr5282638vcb.14.1401353344656; Thu, 29 May 2014 01:49:04 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp11314vcb; Thu, 29 May 2014 01:49:04 -0700 (PDT) X-Received: by 10.180.76.6 with SMTP id g6mr9360582wiw.34.1401353343776; Thu, 29 May 2014 01:49:03 -0700 (PDT) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) by mx.google.com with ESMTPS id dg7si735160wib.63.2014.05.29.01.49.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 May 2014 01:49:03 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 74.125.82.50 as permitted sender) client-ip=74.125.82.50; Received: by mail-wg0-f50.google.com with SMTP id x12so31812wgg.21 for ; Thu, 29 May 2014 01:49:03 -0700 (PDT) X-Received: by 10.194.24.36 with SMTP id r4mr8280788wjf.39.1401353343021; Thu, 29 May 2014 01:49:03 -0700 (PDT) Received: from sundance.lan (cpc4-aztw19-0-0-cust157.18-1.cable.virginm.net. [82.33.25.158]) by mx.google.com with ESMTPSA id k2sm40794wjq.20.2014.05.29.01.49.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 May 2014 01:49:02 -0700 (PDT) From: Daniel Thompson To: Greg Kroah-Hartman Cc: Daniel Thompson , linux-serial@vger.kernel.org, patches@linaro.org, linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, John Stultz , Anton Vorontsov , Colin Cross , kernel-team@android.com, Jason Wessel , kgdb-bugreport@lists.sourceforge.net, Jiri Slaby , Dirk Behme Subject: [PATCH tty-next v2 2/4] serial: kgdb_nmi: Use container_of() to locate private data Date: Thu, 29 May 2014 09:48:44 +0100 Message-Id: <1401353326-14148-3-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1401353326-14148-1-git-send-email-daniel.thompson@linaro.org> References: <20140528200344.GA2750@kroah.com> <1401353326-14148-1-git-send-email-daniel.thompson@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.thompson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This corrects a crash in kgdb_nmi_tty_shutdown() which occurs when the function is called with port->tty set to NULL. All conversions between struct tty_port and struct kgdb_nmi_tty_priv have been switched to direct calls to container_of() to improve code clarity and consistancy. Signed-off-by: Daniel Thompson --- drivers/tty/serial/kgdb_nmi.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c index 5f673b7..d51b2a1 100644 --- a/drivers/tty/serial/kgdb_nmi.c +++ b/drivers/tty/serial/kgdb_nmi.c @@ -84,11 +84,6 @@ struct kgdb_nmi_tty_priv { STRUCT_KFIFO(char, KGDB_NMI_FIFO_SIZE) fifo; }; -static struct kgdb_nmi_tty_priv *kgdb_nmi_port_to_priv(struct tty_port *port) -{ - return container_of(port, struct kgdb_nmi_tty_priv, port); -} - /* * Our debugging console is polled in a tasklet, so we'll check for input * every tick. In HZ-less mode, we should program the next tick. We have @@ -118,7 +113,7 @@ static void kgdb_tty_recv(int ch) * do that, and actually, we can't: we're in NMI context, no locks are * possible. */ - priv = kgdb_nmi_port_to_priv(kgdb_nmi_port); + priv = container_of(kgdb_nmi_port, struct kgdb_nmi_tty_priv, port); kfifo_in(&priv->fifo, &c, 1); kgdb_tty_poke(); } @@ -216,7 +211,8 @@ static void kgdb_nmi_tty_receiver(unsigned long data) static int kgdb_nmi_tty_activate(struct tty_port *port, struct tty_struct *tty) { - struct kgdb_nmi_tty_priv *priv = tty->driver_data; + struct kgdb_nmi_tty_priv *priv = + container_of(port, struct kgdb_nmi_tty_priv, port); kgdb_nmi_port = port; tasklet_schedule(&priv->tlet); @@ -225,7 +221,8 @@ static int kgdb_nmi_tty_activate(struct tty_port *port, struct tty_struct *tty) static void kgdb_nmi_tty_shutdown(struct tty_port *port) { - struct kgdb_nmi_tty_priv *priv = port->tty->driver_data; + struct kgdb_nmi_tty_priv *priv = + container_of(port, struct kgdb_nmi_tty_priv, port); tasklet_kill(&priv->tlet); kgdb_nmi_port = NULL;