Commit e5834ac2 authored by Johan Hovold's avatar Johan Hovold Committed by Samuel Ortiz

NFC: nfcmrvl: use nfc-device for firmware download

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: 3194c687 ("NFC: nfcmrvl: add firmware download support")
Cc: stable <stable@vger.kernel.org>     # 4.4
Cc: Vincent Cuissard <cuissard@marvell.com>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 0cbe4011
...@@ -457,7 +457,7 @@ int nfcmrvl_fw_dnld_init(struct nfcmrvl_private *priv) ...@@ -457,7 +457,7 @@ int nfcmrvl_fw_dnld_init(struct nfcmrvl_private *priv)
INIT_WORK(&priv->fw_dnld.rx_work, fw_dnld_rx_work); INIT_WORK(&priv->fw_dnld.rx_work, fw_dnld_rx_work);
snprintf(name, sizeof(name), "%s_nfcmrvl_fw_dnld_rx_wq", 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); priv->fw_dnld.rx_wq = create_singlethread_workqueue(name);
if (!priv->fw_dnld.rx_wq) if (!priv->fw_dnld.rx_wq)
return -ENOMEM; return -ENOMEM;
...@@ -494,6 +494,7 @@ int nfcmrvl_fw_dnld_start(struct nci_dev *ndev, const char *firmware_name) ...@@ -494,6 +494,7 @@ int nfcmrvl_fw_dnld_start(struct nci_dev *ndev, const char *firmware_name)
{ {
struct nfcmrvl_private *priv = nci_get_drvdata(ndev); struct nfcmrvl_private *priv = nci_get_drvdata(ndev);
struct nfcmrvl_fw_dnld *fw_dnld = &priv->fw_dnld; struct nfcmrvl_fw_dnld *fw_dnld = &priv->fw_dnld;
int res;
if (!priv->support_fw_dnld) if (!priv->support_fw_dnld)
return -ENOTSUPP; return -ENOTSUPP;
...@@ -509,7 +510,9 @@ int nfcmrvl_fw_dnld_start(struct nci_dev *ndev, const char *firmware_name) ...@@ -509,7 +510,9 @@ int nfcmrvl_fw_dnld_start(struct nci_dev *ndev, const char *firmware_name)
*/ */
/* Retrieve FW binary */ /* 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); nfc_err(priv->dev, "failed to retrieve FW %s", firmware_name);
return -ENOENT; return -ENOENT;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment