From patchwork Thu Mar 30 10:15:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9653623 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 81D4C60349 for ; Thu, 30 Mar 2017 10:22:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AEBF28531 for ; Thu, 30 Mar 2017 10:22:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D7B22853B; Thu, 30 Mar 2017 10:22:41 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 0F8DE28531 for ; Thu, 30 Mar 2017 10:22:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933536AbdC3KWX (ORCPT ); Thu, 30 Mar 2017 06:22:23 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:36496 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932989AbdC3KQE (ORCPT ); Thu, 30 Mar 2017 06:16:04 -0400 Received: by mail-lf0-f66.google.com with SMTP id n78so4121166lfi.3; Thu, 30 Mar 2017 03:16:02 -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=oPSGGRkKrW5u1PsDWlKqUaG24Cx6w7zulLrx1DZ4n0wF8Re+Gmjg6DX4koSlfdl+/y tbGn6y1kQtNbiR1yT1yDhPWCutzsLj019ONu3g/Ex4hkDvuYaI0msPb9AHCDGGD56i96 x7qlXE3hTTtqv/8lDO+/7vohSPUrTSHYHPg2sUhypKCK3UaaflcckqGQsnjfysnsgNmY YDzSj+YuMwfYrK/7QbLesoU0Gen9tqn8DzfdBxs8npgbDdh92NPJRChDdD0RYc96+zw+ Qrl3TdxSH3zHdH8BqNkTZsMvGys0NyVMiHEJeVT/E+PZByk3xUdPy3fvvijhACrLdenn 6pUg== 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=tEH0qLn0LWMlz5DmB5nP09WH6R78XsLmuGJuWOH5yLdEzd5IbQ3KPRXsEo8cmsdnyH SvE3RktmvgQTORhIgcJLYeRk4NKApYv223tzpT4iT5/inpgCCh0y6CUc7Uwq3+3RBU7T t2L3ZGIAu4503Gqwjsmy9uFLZNS49TVmtxFnPEgx1ClvzpboHL12vv9Ah36EzrYztjg2 UNjZ6PIUg/tgGjNmHcyl1zJ0+YFSudHXfcGR0nrjImiWMa/48OXlPMtNGbMCPEMliHzL AwGk4az5ucprv2RmzirRqNdv47bK3sggIZ1Q9dmOdsy7X6xGAgIac0zvHMDtfjBjHXVo 8t/g== X-Gm-Message-State: AFeK/H2zjIH+L2iHUhSIAh10wnmS9YbqFW273B4lSpbKW9NPIu4u5vW+sSEl57GD9QLR5Q== X-Received: by 10.25.16.158 with SMTP id 30mr1487218lfq.32.1490868961247; Thu, 30 Mar 2017 03:16:01 -0700 (PDT) Received: from xi.terra ([84.216.234.102]) by smtp.gmail.com with ESMTPSA id v136sm290923lfa.66.2017.03.30.03.15.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Mar 2017 03:15:59 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.89) (envelope-from ) id 1ctX7R-000416-7r; Thu, 30 Mar 2017 12:15:53 +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 v2 2/8] NFC: nfcmrvl_uart: add missing tty-device sanity check Date: Thu, 30 Mar 2017 12:15:36 +0200 Message-Id: <20170330101542.15384-3-johan@kernel.org> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170330101542.15384-1-johan@kernel.org> References: <20170330101542.15384-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);