All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Wei Yongjun <weiyongjun1@huawei.com>
Cc: Kishon Vijay Abraham I <kishon@ti.com>,
	Rob Herring <robh@kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	linux-omap@vger.kernel.org, linux-pci@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH -next  v2] PCI: dwc: pci-dra7xx: use devm_platform_ioremap_resource_byname()
Date: Tue, 05 May 2020 10:54:29 +0000	[thread overview]
Message-ID: <20200505105429.GB13446@e121166-lin.cambridge.arm.com> (raw)
In-Reply-To: <20200429015027.134485-1-weiyongjun1@huawei.com>

On Wed, Apr 29, 2020 at 01:50:27AM +0000, Wei Yongjun wrote:
> platform_get_resource() may fail and return NULL, so we should better
> check it's return value to avoid a NULL pointer dereference a bit later
> in the code. Fix it to use devm_platform_ioremap_resource_byname()
> instead of calling platform_get_resource_byname() and devm_ioremap().
> 
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
> v1 -> v2: use devm_platform_ioremap_resource_byname, suggest by Vignesh
> ---
>  drivers/pci/controller/dwc/pci-dra7xx.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)

Applied to pci/dwc, thanks.

Lorenzo

> diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c
> index 3b0e58f2de58..6184ebc9392d 100644
> --- a/drivers/pci/controller/dwc/pci-dra7xx.c
> +++ b/drivers/pci/controller/dwc/pci-dra7xx.c
> @@ -840,7 +840,6 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
>  	struct phy **phy;
>  	struct device_link **link;
>  	void __iomem *base;
> -	struct resource *res;
>  	struct dw_pcie *pci;
>  	struct dra7xx_pcie *dra7xx;
>  	struct device *dev = &pdev->dev;
> @@ -877,10 +876,9 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
>  		return irq;
>  	}
>  
> -	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ti_conf");
> -	base = devm_ioremap(dev, res->start, resource_size(res));
> -	if (!base)
> -		return -ENOMEM;
> +	base = devm_platform_ioremap_resource_byname(pdev, "ti_conf");
> +	if (IS_ERR(base))
> +		return PTR_ERR(base);
>  
>  	phy_count = of_property_count_strings(np, "phy-names");
>  	if (phy_count < 0) {
> 
> 
> 

WARNING: multiple messages have this Message-ID (diff)
From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Wei Yongjun <weiyongjun1@huawei.com>
Cc: Kishon Vijay Abraham I <kishon@ti.com>,
	Rob Herring <robh@kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	linux-omap@vger.kernel.org, linux-pci@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH -next  v2] PCI: dwc: pci-dra7xx: use devm_platform_ioremap_resource_byname()
Date: Tue, 5 May 2020 11:54:29 +0100	[thread overview]
Message-ID: <20200505105429.GB13446@e121166-lin.cambridge.arm.com> (raw)
In-Reply-To: <20200429015027.134485-1-weiyongjun1@huawei.com>

On Wed, Apr 29, 2020 at 01:50:27AM +0000, Wei Yongjun wrote:
> platform_get_resource() may fail and return NULL, so we should better
> check it's return value to avoid a NULL pointer dereference a bit later
> in the code. Fix it to use devm_platform_ioremap_resource_byname()
> instead of calling platform_get_resource_byname() and devm_ioremap().
> 
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
> v1 -> v2: use devm_platform_ioremap_resource_byname, suggest by Vignesh
> ---
>  drivers/pci/controller/dwc/pci-dra7xx.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)

Applied to pci/dwc, thanks.

Lorenzo

> diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c
> index 3b0e58f2de58..6184ebc9392d 100644
> --- a/drivers/pci/controller/dwc/pci-dra7xx.c
> +++ b/drivers/pci/controller/dwc/pci-dra7xx.c
> @@ -840,7 +840,6 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
>  	struct phy **phy;
>  	struct device_link **link;
>  	void __iomem *base;
> -	struct resource *res;
>  	struct dw_pcie *pci;
>  	struct dra7xx_pcie *dra7xx;
>  	struct device *dev = &pdev->dev;
> @@ -877,10 +876,9 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
>  		return irq;
>  	}
>  
> -	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ti_conf");
> -	base = devm_ioremap(dev, res->start, resource_size(res));
> -	if (!base)
> -		return -ENOMEM;
> +	base = devm_platform_ioremap_resource_byname(pdev, "ti_conf");
> +	if (IS_ERR(base))
> +		return PTR_ERR(base);
>  
>  	phy_count = of_property_count_strings(np, "phy-names");
>  	if (phy_count < 0) {
> 
> 
> 

  reply	other threads:[~2020-05-05 10:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-27 11:10 [PATCH -next] PCI: dwc: pci-dra7xx: Fix potential NULL dereference in dra7xx_pcie_probe() Wei Yongjun
2020-04-27 11:10 ` Wei Yongjun
2020-04-27 11:59 ` Vignesh Raghavendra
2020-04-27 12:11   ` Vignesh Raghavendra
2020-04-28 13:07   ` Dan Carpenter
2020-04-28 13:07     ` Dan Carpenter
2020-04-28 16:15     ` Vignesh Raghavendra
2020-04-28 16:27       ` Vignesh Raghavendra
2020-04-28 17:23       ` Dan Carpenter
2020-04-28 17:23         ` Dan Carpenter
2020-04-29  1:50 ` [PATCH -next v2] PCI: dwc: pci-dra7xx: use devm_platform_ioremap_resource_byname() Wei Yongjun
2020-04-29  1:50   ` Wei Yongjun
2020-05-05 10:54   ` Lorenzo Pieralisi [this message]
2020-05-05 10:54     ` Lorenzo Pieralisi

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=20200505105429.GB13446@e121166-lin.cambridge.arm.com \
    --to=lorenzo.pieralisi@arm.com \
    --cc=bhelgaas@google.com \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kishon@ti.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=vigneshr@ti.com \
    --cc=weiyongjun1@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.