From patchwork Wed Mar 29 16:21:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9651919 X-Patchwork-Delegate: sameo@linux.intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9DBFB60349 for ; Wed, 29 Mar 2017 16:23:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9190628482 for ; Wed, 29 Mar 2017 16:23:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86635284F9; Wed, 29 Mar 2017 16:23:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F9E228482 for ; Wed, 29 Mar 2017 16:23:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932310AbdC2QXU (ORCPT ); Wed, 29 Mar 2017 12:23:20 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:33266 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753152AbdC2QV5 (ORCPT ); Wed, 29 Mar 2017 12:21:57 -0400 Received: by mail-lf0-f67.google.com with SMTP id r36so2176513lfi.0; Wed, 29 Mar 2017 09:21:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=MePPdyr8aPm8cH7p89ER8ne8ifuVBrhZrcNaOOq4Y18=; b=IZLaNThsNKIHJCq1v+jrRKRpAvZFQFZY1kJlKXNKshJaS0AO/gHnRyCRhqY7WUlVtc +LbJswZ4B3jnSVjZ+M2S7mo/RqPY8bfrmnvsp9FAjIzu5QWhKJnzLyBjDAnTen5ACsAT 9j85WaCa4bHuWN0zj4fclRqDwB7214oSgTMNpRPi6913AOdw26BBE5SgjJzX/IrZqDZi 5vJoq/lpBich0CYvr7B/D1+mIs5n6UBUNa6n4zfHyfc72Xb1PYtuzllIrEqDfmn0h/O9 ogPi/IpZWPdbp1NF2HX2EGlriBOp7/3Oor+0p951AUnUpU3vZf7ED+Kil95jwOw4obLA jEfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=MePPdyr8aPm8cH7p89ER8ne8ifuVBrhZrcNaOOq4Y18=; b=AXCiUi/Q6E5sGMVn6V3YsSn+M4nvNPns1vV47rm1j0sUoq66hGCd2LUx57VPyV8Nzc i7l0q5mqjC5oevf+1JklziDpRtUiqrtUIcrwftmFQJzgkFdhKI6CeJjq1bYv7qX2iCuA uXavYqEDIhbt/EO1wjdWXPGdw+BTn/4QnRE/BR3tywbhHr/8oxshkdi4pHW9Xo8gjmIN vPXhSNpi8SkMG3GpSAZr9Z2vFlwuqYj1ntkFbeGICMzxYWR47wHNHjDjLRf3LRMwk87x cfq7d5R6YI2kg+u6ZEVaHWE4736kxL/PgiBmvkq7SaQwp7aq5Q/QCYNiPqgUIQiuT3ll VpKA== X-Gm-Message-State: AFeK/H3YS+GfPkJcoWvRd4DWozAKfzCf2JNKOD1VCZCRdsHICKntx6b2vdPo4/S6Mmw82g== X-Received: by 10.46.1.220 with SMTP id f89mr540355lji.7.1490804514364; Wed, 29 Mar 2017 09:21:54 -0700 (PDT) Received: from xi.terra ([84.216.234.102]) by smtp.gmail.com with ESMTPSA id 191sm1388597lfz.44.2017.03.29.09.21.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Mar 2017 09:21:53 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.89) (envelope-from ) id 1ctGM0-0004jF-Sm; Wed, 29 Mar 2017 18:21:48 +0200 From: Johan Hovold To: Lauro Ramos Venancio , Aloisio Almeida Jr , Samuel Ortiz Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable , Vincent Cuissard Subject: [PATCH 2/7] NFC: nfcmrvl_uart: add missing tty-device sanity check Date: Wed, 29 Mar 2017 18:21:07 +0200 Message-Id: <20170329162112.18121-3-johan@kernel.org> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170329162112.18121-1-johan@kernel.org> References: <20170329162112.18121-1-johan@kernel.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make sure to check the tty-device pointer before trying to access the parent device to avoid dereferencing a NULL-pointer when the tty is one end of a Unix98 pty. Fixes: e097dc624f78 ("NFC: nfcmrvl: add UART driver") Cc: stable # 4.2 Cc: Vincent Cuissard Signed-off-by: Johan Hovold --- drivers/nfc/nfcmrvl/uart.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/nfc/nfcmrvl/uart.c b/drivers/nfc/nfcmrvl/uart.c index 83a99e38e7bd..6c0c301611c4 100644 --- a/drivers/nfc/nfcmrvl/uart.c +++ b/drivers/nfc/nfcmrvl/uart.c @@ -109,6 +109,7 @@ static int nfcmrvl_nci_uart_open(struct nci_uart *nu) struct nfcmrvl_private *priv; struct nfcmrvl_platform_data *pdata = NULL; struct nfcmrvl_platform_data config; + struct device *dev = nu->tty->dev; /* * Platform data cannot be used here since usually it is already used @@ -116,9 +117,8 @@ static int nfcmrvl_nci_uart_open(struct nci_uart *nu) * and check if DT entries were added. */ - if (nu->tty->dev->parent && nu->tty->dev->parent->of_node) - if (nfcmrvl_uart_parse_dt(nu->tty->dev->parent->of_node, - &config) == 0) + if (dev && dev->parent && dev->parent->of_node) + if (nfcmrvl_uart_parse_dt(dev->parent->of_node, &config) == 0) pdata = &config; if (!pdata) { @@ -131,7 +131,7 @@ static int nfcmrvl_nci_uart_open(struct nci_uart *nu) } priv = nfcmrvl_nci_register_dev(NFCMRVL_PHY_UART, nu, &uart_ops, - nu->tty->dev, pdata); + dev, pdata); if (IS_ERR(priv)) return PTR_ERR(priv);