public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Ray Jui <ray.jui@broadcom.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	Bjorn Helgaas <helgaas@kernel.org>,
	linux-kernel@vger.kernel.org,
	bcm-kernel-feedback-list@broadcom.com, linux-pci@vger.kernel.org,
	Rafal Milecki <rafal@milecki.pl>,
	stable@vger.kernel.org
Subject: Re: [PATCH v2] PCI: iproc: Fix NULL pointer dereference for BCMA
Date: Fri, 12 Jan 2018 18:06:05 +0000	[thread overview]
Message-ID: <20180112180605.GA26438@red-moon> (raw)
In-Reply-To: <1515702976-29275-1-git-send-email-ray.jui@broadcom.com>

On Thu, Jan 11, 2018 at 12:36:16PM -0800, Ray Jui wrote:
> With the inbound DMA mapping supported added, the iProc PCIe driver
> parses DT property "dma-ranges" through call to
> "of_pci_dma_range_parser_init". In the case of BCMA, this results in a
> NULL pointer deference due to a missing of_node.
> 
> Fix this by adding a guard in pcie-iproc-platform.c to only enable the
> inbound DMA mapping logic when DT property "dma-ranges" is present
> 
> Fixes: dd9d4e7498de3 ("PCI: iproc: Add inbound DMA mapping support")
> Reported-by: Rafał Miłecki <rafal@milecki.pl>
> Signed-off-by: Ray Jui <ray.jui@broadcom.com>
> Tested-by: Rafał Miłecki <rafal@milecki.pl>
> cc: <stable@vger.kernel.org> # 4.10+
> ---
>  drivers/pci/host/pcie-iproc-platform.c | 7 +++++++
>  drivers/pci/host/pcie-iproc.c          | 8 +++++---
>  drivers/pci/host/pcie-iproc.h          | 2 ++
>  3 files changed, 14 insertions(+), 3 deletions(-)

Applied to pci/dwc for 4.16, thanks.

Lorenzo

> diff --git a/drivers/pci/host/pcie-iproc-platform.c b/drivers/pci/host/pcie-iproc-platform.c
> index a5073a9..32228d4 100644
> --- a/drivers/pci/host/pcie-iproc-platform.c
> +++ b/drivers/pci/host/pcie-iproc-platform.c
> @@ -92,6 +92,13 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
>  		pcie->need_ob_cfg = true;
>  	}
>  
> +	/*
> +	 * DT nodes are not used by all platforms that use the iProc PCIe
> +	 * core driver. For platforms that require explict inbound mapping
> +	 * configuration, "dma-ranges" would have been present in DT
> +	 */
> +	pcie->need_ib_cfg = of_property_read_bool(np, "dma-ranges");
> +
>  	/* PHY use is optional */
>  	pcie->phy = devm_phy_get(dev, "pcie-phy");
>  	if (IS_ERR(pcie->phy)) {
> diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c
> index 935909b..7583606 100644
> --- a/drivers/pci/host/pcie-iproc.c
> +++ b/drivers/pci/host/pcie-iproc.c
> @@ -1378,9 +1378,11 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)
>  		}
>  	}
>  
> -	ret = iproc_pcie_map_dma_ranges(pcie);
> -	if (ret && ret != -ENOENT)
> -		goto err_power_off_phy;
> +	if (pcie->need_ib_cfg) {
> +		ret = iproc_pcie_map_dma_ranges(pcie);
> +		if (ret && ret != -ENOENT)
> +			goto err_power_off_phy;
> +	}
>  
>  #ifdef CONFIG_ARM
>  	pcie->sysdata.private_data = pcie;
> diff --git a/drivers/pci/host/pcie-iproc.h b/drivers/pci/host/pcie-iproc.h
> index a6b55ce..4ac6282 100644
> --- a/drivers/pci/host/pcie-iproc.h
> +++ b/drivers/pci/host/pcie-iproc.h
> @@ -74,6 +74,7 @@ struct iproc_msi;
>   * @ob: outbound mapping related parameters
>   * @ob_map: outbound mapping related parameters specific to the controller
>   *
> + * @need_ib_cfg: indicates SW needs to configure the inbound mapping window
>   * @ib: inbound mapping related parameters
>   * @ib_map: outbound mapping region related parameters
>   *
> @@ -101,6 +102,7 @@ struct iproc_pcie {
>  	struct iproc_pcie_ob ob;
>  	const struct iproc_pcie_ob_map *ob_map;
>  
> +	bool need_ib_cfg;
>  	struct iproc_pcie_ib ib;
>  	const struct iproc_pcie_ib_map *ib_map;
>  
> -- 
> 2.1.4
> 

      reply	other threads:[~2018-01-12 18:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-11 20:36 [PATCH v2] PCI: iproc: Fix NULL pointer dereference for BCMA Ray Jui
2018-01-12 18:06 ` Lorenzo Pieralisi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180112180605.GA26438@red-moon \
    --to=lorenzo.pieralisi@arm.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=bhelgaas@google.com \
    --cc=helgaas@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=rafal@milecki.pl \
    --cc=ray.jui@broadcom.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox