From patchwork Wed Mar 29 16:21:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9651905 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 912B260349 for ; Wed, 29 Mar 2017 16:22:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82F5F284D6 for ; Wed, 29 Mar 2017 16:22:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 761F3284F2; Wed, 29 Mar 2017 16:22:39 +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 0FE7828482 for ; Wed, 29 Mar 2017 16:22:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753985AbdC2QWF (ORCPT ); Wed, 29 Mar 2017 12:22:05 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:34741 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752805AbdC2QV6 (ORCPT ); Wed, 29 Mar 2017 12:21:58 -0400 Received: by mail-lf0-f67.google.com with SMTP id x137so2166369lff.1; Wed, 29 Mar 2017 09:21:56 -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=JdtHn7OYhjC7Dp2K46TBTHshckbCsdb5Z0mdU3Kd4qE=; b=gX2sCpgx6BO2oSWgNwzHb0Rzxyw1DO4gcy4YkJAPjx4GD6fCUi4mqnGLo6Y25I+yty P9CFzul1BdijSd08BZOUWXH+TGGvvrqE2lRrf+boWJB7R0HyfDY6HuF/uTaMX0q0Fh2L 55hDrp0znOn6HH3jx2DaoQkQFbbQoYunyBlqItHc740bdzPD5E+04QaInFcy4aFIKg9n dBCY2qfGqnc2IfnEK67hSEfQN4pfe82xKljoKxsgdMvTr4gQntiaJQC0ga7z+1rkege5 +vQ4GCGAsjoU4CBij9iHz1Ghz+9SKh6s/nA3biGFDFEu9JRTa9L23ID6bSUM5E6JHxDJ NJhQ== 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=JdtHn7OYhjC7Dp2K46TBTHshckbCsdb5Z0mdU3Kd4qE=; b=cr0kPmaBOn7TA2ZidatFYWbDIbhGrH/I0dEjLoTwmvTcyyfH2xKCgFaBMFmQcq4OCq pTCVW8FmID3Qi5ihpAycPwqZkMUx3HejE7S/es4MGG31As1DBZcGl7IKjTSEDS7B5E4s O6NQ9Bg8pjFrTx5NEmC9k0wq6hTvGvlzq7BlwVyuqxv7K5cLVy0AXpk7/HbMGPNLbntA j0+eKln2UBHtr7z1B37qbIF/xeNeZrNoLuymqU0Cg60JuBmLI2jpaPafX5PXsD5EQyuv 95AdwYTh0thlzZMWuNmrQ5PD7y+pRHOi8eo1+y/Z41AjarANbDOeyLdamWO56j54xubx b5DA== X-Gm-Message-State: AFeK/H2f0Is6KBu+ONBS2QZPSmA96F8Cef4MAofngN72+jqNXlAW6IzbIC8PdZr05DagIA== X-Received: by 10.25.21.229 with SMTP id 98mr449421lfv.161.1490804515955; Wed, 29 Mar 2017 09:21:55 -0700 (PDT) Received: from xi.terra ([84.216.234.102]) by smtp.gmail.com with ESMTPSA id m18sm1386230ljb.8.2017.03.29.09.21.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Mar 2017 09:21:54 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.89) (envelope-from ) id 1ctGM1-0004jP-1Z; Wed, 29 Mar 2017 18:21:49 +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 4/7] NFC: nfcmrvl: use nfc-device for firmware download Date: Wed, 29 Mar 2017 18:21:09 +0200 Message-Id: <20170329162112.18121-5-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 Use the nfc- rather than phy-device in firmware-management code that needs a valid struct device. This specifically fixes a NULL-pointer dereference in nfcmrvl_fw_dnld_init() during registration when the underlying tty is one end of a Unix98 pty. Note that the driver still uses the phy device for any debugging, which is fine for now. Fixes: 3194c6870158 ("NFC: nfcmrvl: add firmware download support") Cc: stable # 4.4 Cc: Vincent Cuissard Signed-off-by: Johan Hovold --- drivers/nfc/nfcmrvl/fw_dnld.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/nfc/nfcmrvl/fw_dnld.c b/drivers/nfc/nfcmrvl/fw_dnld.c index f8dcdf4b24f6..af62c4c854f3 100644 --- a/drivers/nfc/nfcmrvl/fw_dnld.c +++ b/drivers/nfc/nfcmrvl/fw_dnld.c @@ -459,7 +459,7 @@ int nfcmrvl_fw_dnld_init(struct nfcmrvl_private *priv) INIT_WORK(&priv->fw_dnld.rx_work, fw_dnld_rx_work); snprintf(name, sizeof(name), "%s_nfcmrvl_fw_dnld_rx_wq", - dev_name(priv->dev)); + dev_name(&priv->ndev->nfc_dev->dev)); priv->fw_dnld.rx_wq = create_singlethread_workqueue(name); if (!priv->fw_dnld.rx_wq) return -ENOMEM; @@ -496,6 +496,7 @@ int nfcmrvl_fw_dnld_start(struct nci_dev *ndev, const char *firmware_name) { struct nfcmrvl_private *priv = nci_get_drvdata(ndev); struct nfcmrvl_fw_dnld *fw_dnld = &priv->fw_dnld; + int res; if (!priv->support_fw_dnld) return -ENOTSUPP; @@ -511,7 +512,9 @@ int nfcmrvl_fw_dnld_start(struct nci_dev *ndev, const char *firmware_name) */ /* Retrieve FW binary */ - if (request_firmware(&fw_dnld->fw, firmware_name, priv->dev) < 0) { + res = request_firmware(&fw_dnld->fw, firmware_name, + &ndev->nfc_dev->dev); + if (res < 0) { nfc_err(priv->dev, "failed to retrieve FW %s", firmware_name); return -ENOENT; }