From patchwork Thu Mar 30 10:15:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9653611 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 3FC5260349 for ; Thu, 30 Mar 2017 10:21:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AA452856A for ; Thu, 30 Mar 2017 10:21:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DC4828583; Thu, 30 Mar 2017 10:21:31 +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 CD3B42856A for ; Thu, 30 Mar 2017 10:21:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933255AbdC3KQL (ORCPT ); Thu, 30 Mar 2017 06:16:11 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:35005 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933107AbdC3KQF (ORCPT ); Thu, 30 Mar 2017 06:16:05 -0400 Received: by mail-lf0-f66.google.com with SMTP id v2so4125202lfi.2; Thu, 30 Mar 2017 03:16:03 -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=g5I3QpugPb5QuBAK+NaWNH0TBBXjKAexGMClxiQnEe3J8SNNnDMu3/uhHNBdKDS4Sw 3wnwDwjhrff45GT4uCqlLFOrZNHkKb9tRcToiovYjC82BeJH3YJtpmTK6XcBXa7RZK1v /4O+aUYXGIN0IXTHu6FOH2NWB8AcM5n+Hrh23/wPZrbB2K+JfKSBAToeGcZi3k8Uidzx FHiucVqSD8CvOoc2iLLzNFa6ofjA7HmRqGHImSFWMeP2Nzoh1e9gQsrW1CRbXu4k66/Y x1LTq5iqbLN1JUR/nssFiKVgI3zr0A3To5L3/2irTl2BxH/swAVlAnepVVkUaSizVS3b 3aCg== 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=HBa48TAyH0QtxfbwTycam6fgXtzJsnD5enlC5LT7ap7MdSj89jo/JCs++xhmwZX9KM Kzn7GyZCVK/LPNH4n2jYgTSOY2093dqLP/EdOMwEZRlqBZbJflpuMpYN42GIul71mMAF Yi72tOypzx1GoiOK9m2VzbtO9fd/wP7hDrVKXbEMOHMRLCTvntMOwWRqOuusPejbI4a1 OAmq7+lyaA7zk6rDq4I7DRGatiiXeqJXLItAhoO8izhImXMjQ5aE2R19h8LU5xjwCHhy xoJvsfJxXUGxNKEU2oTgrvey+VqsS3jrPH0ZZ2R3xaeOfbYhj19cVTIoQ6lqABirGf0q Q0mA== X-Gm-Message-State: AFeK/H3X2ArkwgSMJPiH6MdLW2HH2ZikoJXbe7E/nop1aUvDLrQyWPBT7OaVQOpOFLWH9Q== X-Received: by 10.25.67.29 with SMTP id q29mr1541790lfa.72.1490868962520; Thu, 30 Mar 2017 03:16:02 -0700 (PDT) Received: from xi.terra ([84.216.234.102]) by smtp.gmail.com with ESMTPSA id o80sm285920lff.25.2017.03.30.03.15.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Mar 2017 03:16:01 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.89) (envelope-from ) id 1ctX7R-00041G-Cv; 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 4/8] NFC: nfcmrvl: use nfc-device for firmware download Date: Thu, 30 Mar 2017 12:15:38 +0200 Message-Id: <20170330101542.15384-5-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 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; }