From patchwork Wed May 14 14:55:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 30167 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 28B5E2055D for ; Wed, 14 May 2014 14:56:01 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id wo20sf9202512obc.11 for ; Wed, 14 May 2014 07:56:00 -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=anLA+/bZmA5w05pgjR28NngW6B1jR3/rMVJ3LkFWX53+BIGByz4e1M5DucMPCbR6Cy KBcNvk8fMCgF/A6c5VIKAmnW9W6JrxB68S16/zha3pumtsaIX1gltHakZZ5FgM5gqNCH RkcxANecj9yJKwamI93JB+7wRn7dCqCeQuHdyy35kHfi605AsfhG17yNjQdDNMFH+6AD 0wJ//i9+2ynA+u08J8OKR5SBZvzKV8WpE68IY0+mSIv0mobbOlhszgD/75dcPDI3FWwZ nPgTynzKgNWMCQU3B5jJ04wc8U024whcslX6eQKQbdbfNRGBgByupt/H5PvY0SKibnRo 4XIA== X-Gm-Message-State: ALoCoQnoVR11vvqfTfLySGHiXL/J7w5CRPk2OO4mkRaB96I7z1jotJizpvSqeSkJjeEHzA7vA/t9 X-Received: by 10.50.178.200 with SMTP id da8mr2379114igc.6.1400079360793; Wed, 14 May 2014 07:56:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.47.82 with SMTP id l76ls2553287qga.61.gmail; Wed, 14 May 2014 07:56:00 -0700 (PDT) X-Received: by 10.220.94.8 with SMTP id x8mr187507vcm.67.1400079360690; Wed, 14 May 2014 07:56:00 -0700 (PDT) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id rz3si365659veb.133.2014.05.14.07.56.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 14 May 2014 07:56:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.169 as permitted sender) client-ip=209.85.128.169; Received: by mail-ve0-f169.google.com with SMTP id jx11so2571379veb.0 for ; Wed, 14 May 2014 07:56:00 -0700 (PDT) X-Received: by 10.58.18.198 with SMTP id y6mr3475840ved.31.1400079360531; Wed, 14 May 2014 07:56:00 -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 ib8csp246937vcb; Wed, 14 May 2014 07:55:59 -0700 (PDT) X-Received: by 10.180.36.212 with SMTP id s20mr26550288wij.18.1400079359510; Wed, 14 May 2014 07:55:59 -0700 (PDT) Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com [209.85.212.169]) by mx.google.com with ESMTPS id cj5si780883wjb.74.2014.05.14.07.55.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 14 May 2014 07:55:59 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.212.169 as permitted sender) client-ip=209.85.212.169; Received: by mail-wi0-f169.google.com with SMTP id hi2so8859024wib.0 for ; Wed, 14 May 2014 07:55:58 -0700 (PDT) X-Received: by 10.180.93.101 with SMTP id ct5mr3874354wib.23.1400079358898; Wed, 14 May 2014 07:55:58 -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 ho2sm4412630wib.15.2014.05.14.07.55.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 May 2014 07:55:57 -0700 (PDT) From: Daniel Thompson To: Greg Kroah-Hartman , linux-serial@vger.kernel.org Cc: patches@linaro.org, linaro-kernel@lists.linaro.org, Daniel Thompson , linux-kernel@vger.kernel.org, John Stultz , Anton Vorontsov , Colin Cross , kernel-team@android.com, Jason Wessel , kgdb-bugreport@lists.sourceforge.net, Jiri Slaby Subject: [PATCH 2/4] serial: kgdb_nmi: Use container_of() to locate private data Date: Wed, 14 May 2014 15:55:33 +0100 Message-Id: <1400079335-32125-3-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1400079335-32125-1-git-send-email-daniel.thompson@linaro.org> References: <1400079335-32125-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.128.169 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;